loopbackio / loopback-connector-postgresql

PostgreSQL connector for LoopBack.
Other
117 stars 180 forks source link

Index is not getting created #323

Closed Merisho closed 6 years ago

Merisho commented 6 years ago

Hello. I have encountered case when autoupdate doesn't create index in PostgreSQL. Documentation says that indexes have to be created with autoupdate or automigrate, so I am confused. Appreciate any feedback, thank you.

Description/Steps to reproduce

  1. Define indexes in model's JSON definition, example of indexes defined in my model: MyModel.json

    "indexes": {
        "device_type_name_unique": {
            "keys": {
                "name": 1
            },
            "options": {
                "unique": true
            }
        },
    
        "device_type_pk": {
            "keys": {
                "id": 1
            },
            "options": {
                "primaryKey": true
            }
        }
    }
  2. Create model using loopback data source and run autoupdate:

    const modelSchema = require(`../common/models/MyModel.json`);
    dataSource.createModel(modelSchema.name, modelSchema.properties, modelSchema.options);
    dataSource.autoupdate(err => {
    if(err) {
      console.error(err);
      return;
    }
    console.log('Autoupdate success');
    });
  3. Observe table in PostgreSQL

Expected result

_device_type_nameunique and _device_typepk constraints are created

Actual result

Only _device_typepkey constraint is created

Additional information

Platform, Node version

win32 x64 9.3.0

npm ls

+-- loopback@3.18.2 +-- UNMET DEPENDENCY loopback-boot@2.27.0 +-- loopback-component-explorer@4.3.0 +-- loopback-connector-postgresql@2.9.0 npm ERR! missing: compression@1.7.1, required by devicehive-server-backend-node@1.0.0 npm ERR! missing: json-evn-configurator@1.0.5, required by devicehive-server-backend-node@1.0.0 npm ERR! missing: loopback-boot@2.27.0, required by devicehive-server-backend-node@1.0.0 npm ERR! missing: compressible@2.0.12, required by compression@1.7.1 npm ERR! missing: debug@2.6.9, required by compression@1.7.1 npm ERR! missing: debug@2.6.9, required by loopback-boot@2.27.0 npm ERR! missing: lodash@3.10.1, required by loopback-boot@2.27.0 npm ERR! missing: strong-globalize@2.10.0, required by loopback-boot@2.27.0 npm ERR! missing: async@1.5.2, required by strong-globalize@2.10.0 npm ERR! missing: debug@3.1.0, required by strong-globalize@2.10.0 npm ERR! missing: lodash@4.17.4, required by strong-globalize@2.10.0

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 6 years ago

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

cjonestcgsi commented 4 years ago

seeing this issue in loopback2