diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ad2c50..859da2a 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,26 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.6.18.2](https://github.com/fabrix-app/spool-sequelize/compare/v1.6.20...v1.6.18.2) (2020-10-19) + + +### Bug Fixes + +* fixes broken version ([7c6c884](https://github.com/fabrix-app/spool-sequelize/commit/7c6c8841f806afed2b743f4e4a6393053edb6a1c)) +* fixes store.models migration selection ([debf276](https://github.com/fabrix-app/spool-sequelize/commit/debf2762faf4604f3623d3868972118d1edd51f4)) + +## [1.6.18.1](https://github.com/fabrix-app/spool-sequelize/compare/v1.6.18...v1.6.18.1) (2020-10-19) + + +### Bug Fixes + +* fixes store.models migration selection ([debf276](https://github.com/fabrix-app/spool-sequelize/commit/debf2762faf4604f3623d3868972118d1edd51f4)) + ### [1.6.20](https://github.com/fabrix-app/spool-sequelize/compare/v1.6.19...v1.6.20) (2019-10-24) ### [1.6.19](https://github.com/fabrix-app/spool-sequelize/compare/v1.6.18...v1.6.19) (2019-10-24) + ### [1.6.18](https://github.com/fabrix-app/spool-sequelize/compare/v1.6.17...v1.6.18) (2019-10-21) @@ -29,4 +45,4 @@ Add better validation errors for Footprints Return not found error if model is not found ## v0.0.3 -Initial version +Initial version diff --git a/lib/SequelizeResolver.ts b/lib/SequelizeResolver.ts index ca772b8..e97baba 100644 --- a/lib/SequelizeResolver.ts +++ b/lib/SequelizeResolver.ts @@ -103,6 +103,9 @@ export class SequelizeResolver extends FabrixResolver { this._sequelizeModel.app = this.app // this._sequelizeModel.model = this.model + // Set the config for migrate on the sequelize model + this._sequelizeModel.migrate = this.model.migrate + // A helpful exposure of the instance of Sequelize being used this._sequelize = this._sequelizeModel.sequelize this.model.datastore = this.model['sequelize'] = this.datastore diff --git a/lib/api/services/SchemaMigrationService.ts b/lib/api/services/SchemaMigrationService.ts index bf3aff1..f44e60c 100755 --- a/lib/api/services/SchemaMigrationService.ts +++ b/lib/api/services/SchemaMigrationService.ts @@ -34,17 +34,20 @@ export class SchemaMigrationService extends Service { migrateModels(models, connection) { let promises = [] Object.entries(models).forEach(([ _, model ]: [ any, {[key: string]: any}]) => { + + console.log('BRK MODEL MIGRATE', _, model.migrate) + if (model.migrate === 'drop') { promises.push(this.dropModel(model, connection)) } else if (model.migrate === 'alter') { promises.push(this.alterModel(model, connection)) } - else if (model.migrate === 'none') { - return + else if (model.migrate === 'none' || model.migrate === 'safe') { + // placeholders } else { - return + // placeholders } }) return promises @@ -89,9 +92,6 @@ export class SchemaMigrationService extends Service { else if (store.migrate === 'alter') { promises.push(this.alterDB(store)) } - else if (store.migrate === 'none') { - return - } else { promises = [...promises, ...this.migrateModels(store.models, store)] } diff --git a/lib/transformer.ts b/lib/transformer.ts index 6a7d97b..19995d9 100755 --- a/lib/transformer.ts +++ b/lib/transformer.ts @@ -229,6 +229,9 @@ export const Transformer = { model.resolver.connection = connection model.resolver.connect(modelName, schema, options) + // Assign the model to the connection models + // connection.models[modelName] = model + return model }, @@ -367,8 +370,11 @@ export const Transformer = { const _sequelize = {} Object.keys(stores).forEach(key => { _sequelize[key] = Transformer.createConnectionsFromConfig(app, sequelize, key, stores[key], plugins) + // Set fabrix to the store _sequelize[key].fabrixApp = app + // Add the migrate onto the store _sequelize[key].migrate = stores[key].migrate + // Declare models now, so that they are never undefined _sequelize[key].models = {} }) diff --git a/package-lock.json b/package-lock.json index f053a6b..5fd1f5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@fabrix/spool-sequelize", - "version": "1.6.20", + "version": "1.6.18-3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -180,6 +180,11 @@ "winston": "^3.2.1" } }, + "@types/geojson": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-1.0.6.tgz", + "integrity": "sha512-Xqg/lIZMrUd0VRmSRbCAewtwGZiAk3mEUDvV4op1tGl+LvyPcb/MIOSxTl9z+9+J+R4/vpjiCAT4xeKzH9ji1w==" + }, "@types/lodash": { "version": "4.14.144", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.144.tgz", @@ -246,11 +251,6 @@ "color-convert": "^1.9.0" } }, - "any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=" - }, "append-transform": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-1.0.0.tgz", @@ -376,9 +376,9 @@ } }, "bluebird": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.1.tgz", - "integrity": "sha512-DdmyoGCleJnkbp3nkbxTLJ18rjDsE4yCggEwKNXkeV123sPNfOCYeDoeuOY+F2FrSjO1YXcTU+dsy96KMy+gcg==" + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, "boom": { "version": "7.3.0", @@ -987,6 +987,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, "requires": { "ms": "^2.1.1" } @@ -1051,6 +1052,11 @@ "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "dev": true }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, "detect-indent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.0.0.tgz", @@ -1151,9 +1157,9 @@ } }, "dottie": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.1.tgz", - "integrity": "sha512-ch5OQgvGDK2u8pSZeSYAQaV/lczImd7pMJ7BcEPXmnFVjy4yJIzP6CsODJUTH8mg1tyH1Z2abOiuJO3DjZ/GBw==" + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.2.tgz", + "integrity": "sha512-fmrwR04lsniq/uSr8yikThDTrM7epXHBAAjH9TbeH3rEA8tdCO7mRzB9hdmdGyJCxF8KERo9CITcm3kGuoyMhg==" }, "ecc-jsbn": { "version": "0.1.2", @@ -1499,6 +1505,11 @@ } } }, + "generic-pool": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.5.0.tgz", + "integrity": "sha512-dEkxmX+egB2o4NR80c/q+xzLLzLX+k68/K8xv81XprD+Sk7ZtP14VugeCz+fUwv5FzpWq40pPtAkzPRqT8ka9w==" + }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -2727,14 +2738,14 @@ "dev": true }, "moment": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", - "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" }, "moment-timezone": { - "version": "0.5.27", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.27.tgz", - "integrity": "sha512-EIKQs7h5sAsjhPCqN6ggx6cEbs94GK050254TIJySD1bzoM5JTYDwAU1IoVOeTOL6Gm27kYJ51/uuvq1kIlrbw==", + "version": "0.5.31", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.31.tgz", + "integrity": "sha512-+GgHNg8xRhMXfEbv81iDtrVeTcWt0kWmTEY1XQK14dICTXnWJnT0dxdlPspwqF3keKMVPXwayEsk1DI0AA/jdA==", "requires": { "moment": ">= 2.9.0" } @@ -3539,11 +3550,27 @@ "dev": true }, "retry-as-promised": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-3.2.0.tgz", - "integrity": "sha512-CybGs60B7oYU/qSQ6kuaFmRd9sTZ6oXSc0toqePvV74Ac6/IFZSI1ReFQmtCN+uvW1Mtqdwpvt/LGOiCBAY2Mg==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-2.3.2.tgz", + "integrity": "sha1-zZdO5P2bX+A8vzGHHuSCIcB3N7c=", "requires": { - "any-promise": "^1.3.0" + "bluebird": "^3.4.6", + "debug": "^2.6.9" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } } }, "rimraf": { @@ -3592,43 +3619,42 @@ "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", - "dev": true + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" }, "sequelize": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-5.21.1.tgz", - "integrity": "sha512-JI+53MwcClfCFUPJT/l2dDzSpEzWAueyCZus33L/yhJxKTisfdd9OHrUPQ6/dI5nR5eIYT/EafrjkqTAlEQS2w==", + "version": "4.44.4", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-4.44.4.tgz", + "integrity": "sha512-nkHmYkbwQK7uwpgW9VBalCBnQqQ8mslTdgcBthtJLORuPvAYRPlfkXZMVUU9TLLJt9CX+/y0MYg0DpcP6ywsEQ==", "requires": { "bluebird": "^3.5.0", "cls-bluebird": "^2.1.0", - "debug": "^4.1.1", + "debug": "^3.1.0", + "depd": "^1.1.0", "dottie": "^2.0.0", + "generic-pool": "3.5.0", "inflection": "1.12.0", - "lodash": "^4.17.15", - "moment": "^2.24.0", - "moment-timezone": "^0.5.21", - "retry-as-promised": "^3.2.0", - "semver": "^6.3.0", - "sequelize-pool": "^2.3.0", + "lodash": "^4.17.1", + "moment": "^2.20.0", + "moment-timezone": "^0.5.14", + "retry-as-promised": "^2.3.2", + "semver": "^5.5.0", + "terraformer-wkt-parser": "^1.1.2", "toposort-class": "^1.0.1", - "uuid": "^3.3.3", - "validator": "^10.11.0", - "wkx": "^0.4.8" + "uuid": "^3.2.1", + "validator": "^10.4.0", + "wkx": "^0.4.1" }, "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } } } }, - "sequelize-pool": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-2.3.0.tgz", - "integrity": "sha512-Ibz08vnXvkZ8LJTiUOxRcj1Ckdn7qafNZ2t59jYHMX1VIebTAOYefWdRYFt6z6+hy52WGthAHAoLc9hvk3onqA==" - }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", @@ -3996,6 +4022,23 @@ } } }, + "terraformer": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/terraformer/-/terraformer-1.0.12.tgz", + "integrity": "sha512-MokUp0+MFal4CmJDVL6VAO1bKegeXcBM2RnPVfqcFIp2IIv8EbPAjG0j/vEy/vuKB8NVMMSF2vfpVS/QLe4DBg==", + "requires": { + "@types/geojson": "^7946.0.0 || ^1.0.0" + } + }, + "terraformer-wkt-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/terraformer-wkt-parser/-/terraformer-wkt-parser-1.2.1.tgz", + "integrity": "sha512-+CJyNLWb3lJ9RsZMTM66BY0MT3yIo4l4l22Jd9CrZuwzk54fsu4Sc7zejuS9fCITTuTQy3p06d4MZMVI7v5wSg==", + "requires": { + "@types/geojson": "^1.0.0", + "terraformer": "~1.0.5" + } + }, "test-exclude": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-5.2.3.tgz", diff --git a/package.json b/package.json index ee58ae2..e72454f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fabrix/spool-sequelize", - "version": "1.6.20", + "version": "1.6.18-3", "description": "Spool - Datastore Spool for Sequelize.js http://sequelizejs.com", "scripts": { "release": "standard-version", @@ -55,7 +55,7 @@ "joi": "^14.3.1", "lodash": "^4.17.15", "merge-options": "^2.0.0", - "sequelize": "^5.21.1" + "sequelize": "^4.43.0" }, "devDependencies": { "@fabrix/fabrix": "^1.6.4",