diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 032cb988..f63bbe65 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -37,7 +37,7 @@ jobs: run: npm cache verify - name: install sequelize-cli globally - run: npm i -g sequelize-cli@6.3.0 + run: npm i -g sequelize-cli - name: install cross-env globally run: npm install -g cross-env diff --git a/.gitignore b/.gitignore index b0eb781f..52d32deb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. data.sqlite3 test.sqlite3 -testMirror.sqlite +testMirror.sqlite3 # dependencies /node_modules diff --git a/migrations/20220115134849-add-orgUid-index.cjs b/migrations/20220115134849-add-orgUid-index.cjs new file mode 100644 index 00000000..506577ce --- /dev/null +++ b/migrations/20220115134849-add-orgUid-index.cjs @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = { + async up(queryInterface, Sequelize) { + queryInterface.addIndex('Projects', ['orgUid']); + queryInterface.addIndex('Units', ['orgUid']); + }, + + async down(queryInterface, Sequelize) { + /** + * Add reverting commands here. + * + * Example: + * await queryInterface.dropTable('users'); + */ + }, +}; diff --git a/src/models/units/units.model.js b/src/models/units/units.model.js index 50fc24b5..ea1a1477 100644 --- a/src/models/units/units.model.js +++ b/src/models/units/units.model.js @@ -9,7 +9,7 @@ import rxjs from 'rxjs'; const { Model } = Sequelize; -const virtualColumns = { +const virtualFields = { unitBlockStart: { type: Sequelize.VIRTUAL, get() { @@ -48,7 +48,7 @@ const virtualColumns = { class Unit extends Model { static changes = new rxjs.Subject(); static defaultColumns = Object.keys( - Object.assign({}, ModelTypes, virtualColumns), + Object.assign({}, ModelTypes, virtualFields), ); static associate() { @@ -102,7 +102,7 @@ class Unit extends Model { }; // Check if we need to include the virtual field dep - for (const col of Object.keys(virtualColumns)) { + for (const col of Object.keys(virtualFields)) { if (columns.includes(col)) { if (!columns.includes('serialNumberBlock')) { columns.push('serialNumberBlock'); @@ -231,7 +231,7 @@ class Unit extends Model { } } -Unit.init(Object.assign({}, ModelTypes, virtualColumns), { +Unit.init(Object.assign({}, ModelTypes, virtualFields), { sequelize, modelName: 'unit', foreignKey: 'unitId', diff --git a/testMirror.sqlite3 b/testMirror.sqlite3 deleted file mode 100644 index ef5f34e3..00000000 Binary files a/testMirror.sqlite3 and /dev/null differ