From 8e04ce214b99e22c6c90ad73625660d81997464f Mon Sep 17 00:00:00 2001 From: Sushant Date: Sun, 21 Jun 2020 15:58:04 +0530 Subject: [PATCH] feat: modernize assets & skeleton files (#909) --- .github/stale.yml | 16 +++++ package.json | 3 +- src/assets/migrations/create-table.js | 49 +++++++-------- src/assets/migrations/skeleton.js | 30 +++++---- src/assets/models/model.js | 21 +++++-- src/assets/seeders/skeleton.js | 34 +++++----- src/commands/model_generate.js | 1 - src/core/migrator.js | 15 +---- src/sequelize.js | 14 ++--- test/db/migrate-json.test.js | 3 +- test/db/migrate.test.js | 3 +- test/migration/create.test.js | 4 +- test/model/create.test.js | 12 ++-- test/seed/create.test.js | 4 +- .../migrations/20111117063700-createPerson.js | 29 ++++----- .../20111130161100-emptyMigration.js | 10 +-- .../20111205064000-renamePersonToUser.js | 14 ++--- ...20111205162700-addSignatureColumnToUser.js | 62 +++++-------------- ...0111205167000-addUniqueNameColumnToUser.js | 31 ++++------ ...111206061400-removeShopIdColumnFromUser.js | 19 +++--- ...-changeSignatureColumnOfUserToMendatory.js | 16 ++--- ...163300-renameSignatureColumnOfUserToSig.js | 14 ++--- ...0130909174103-createFunctionGetAnAnswer.js | 20 +++--- ...3-renameFunctionGetAnAnswerGetTheAnswer.js | 14 ++--- ...130909175000-deleteFunctionGetTheAnswer.js | 19 +++--- ...0130909175939-createTestTableForTrigger.js | 31 ++++------ ...9180846-createTriggerOnTriggerTestTable.js | 29 ++++----- ...renameTriggerUpdatedAtToUpdateUpdatedAt.js | 22 ++++--- ...0909185621-deleteTriggerUpdateUpdatedAt.js | 29 ++++----- .../migrations/20170526153000-createPost.js | 21 +++---- .../cjs/20200617063700-createComment.cjs | 18 +++--- .../invalid/20141208213500-createPerson.js | 11 ++-- .../new/20141208213500-createPerson.js | 13 ++-- .../seeders/20111117063700-seedPerson.js | 25 ++++---- .../seeders/20111117063900-seedPerson2.js | 26 ++++---- .../seeders/new/20141208213500-seedPerson.js | 15 ++--- 36 files changed, 310 insertions(+), 387 deletions(-) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 00000000..c0ed00d2 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,16 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - bug + - feature + - semver:major +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + 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. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/package.json b/package.json index 64631885..fb27c878 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "gulp": "^4.0.0", "mocha": "^6.0.0", "mysql2": "latest", - "nodeify": "^1.0.1", "pg": "latest", "pg-hstore": "latest", "sequelize": "latest", @@ -38,7 +37,7 @@ "through2": "^3.0.0" }, "options": { - "mocha": "--require scripts/mocha-bootload.js --check-leaks --exit --timeout 30000 --colors --recursive --reporter spec" + "mocha": "--require scripts/mocha-bootload.js --bail --check-leaks --exit --timeout 30000 --colors --recursive --reporter spec" }, "eslintIgnore": [ "test/support", diff --git a/src/assets/migrations/create-table.js b/src/assets/migrations/create-table.js index 1fd3e92d..1a6c0ca5 100644 --- a/src/assets/migrations/create-table.js +++ b/src/assets/migrations/create-table.js @@ -1,35 +1,34 @@ 'use strict'; module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface - .createTable('<%= tableName %>', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - - <% attributes.forEach(function(attribute) { %> - <%= attribute.fieldName %>: { - type: Sequelize.<%= attribute.dataFunction ? `${attribute.dataFunction.toUpperCase()}(Sequelize.${attribute.dataType.toUpperCase()})` : attribute.dataValues ? `${attribute.dataType.toUpperCase()}(${attribute.dataValues})` : attribute.dataType.toUpperCase() %> - }, - <% }) %> + up: async (queryInterface, Sequelize) => { + await queryInterface.createTable('<%= tableName %>', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, - <%= createdAt %>: { - allowNull: false, - type: Sequelize.DATE + <% attributes.forEach(function(attribute) { %> + <%= attribute.fieldName %>: { + type: Sequelize.<%= attribute.dataFunction ? `${attribute.dataFunction.toUpperCase()}(Sequelize.${attribute.dataType.toUpperCase()})` : attribute.dataValues ? `${attribute.dataType.toUpperCase()}(${attribute.dataValues})` : attribute.dataType.toUpperCase() %> }, + <% }) %> + + <%= createdAt %>: { + allowNull: false, + type: Sequelize.DATE + }, - <%= updatedAt %>: { - allowNull: false, - type: Sequelize.DATE - } - }); + <%= updatedAt %>: { + allowNull: false, + type: Sequelize.DATE + } + }); }, - down: (queryInterface, Sequelize) => { - return queryInterface.dropTable('<%= tableName %>'); + down: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('<%= tableName %>'); } }; diff --git a/src/assets/migrations/skeleton.js b/src/assets/migrations/skeleton.js index 9ef68be8..49064bf5 100644 --- a/src/assets/migrations/skeleton.js +++ b/src/assets/migrations/skeleton.js @@ -1,23 +1,21 @@ 'use strict'; module.exports = { - up: (queryInterface, Sequelize) => { - /* - Add altering commands here. - Return a promise to correctly handle asynchronicity. - - Example: - return queryInterface.createTable('users', { id: Sequelize.INTEGER }); - */ + up: async (queryInterface, Sequelize) => { + /** + * Add altering commands here. + * + * Example: + * await queryInterface.createTable('users', { id: Sequelize.INTEGER }); + */ }, - down: (queryInterface, Sequelize) => { - /* - Add reverting commands here. - Return a promise to correctly handle asynchronicity. - - Example: - return queryInterface.dropTable('users'); - */ + down: async (queryInterface, Sequelize) => { + /** + * Add reverting commands here. + * + * Example: + * await queryInterface.dropTable('users'); + */ } }; diff --git a/src/assets/models/model.js b/src/assets/models/model.js index 70007aa5..84924b31 100644 --- a/src/assets/models/model.js +++ b/src/assets/models/model.js @@ -1,18 +1,29 @@ 'use strict'; +const { Model } = require('sequelize'); + module.exports = (sequelize, DataTypes) => { - const <%= name %> = sequelize.define('<%= name %>', { + class <%= name %> extends Model { + /** + * Helper method for defining associations. + * This method is not part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate (models) { + // define association here + } + }; + + <%= name %>.init({ <% attributes.forEach(function(attribute, index) { %> <%= attribute.fieldName %>: DataTypes.<%= attribute.dataFunction ? `${attribute.dataFunction.toUpperCase()}(DataTypes.${attribute.dataType.toUpperCase()})` : attribute.dataValues ? `${attribute.dataType.toUpperCase()}(${attribute.dataValues})` : attribute.dataType.toUpperCase() %> <%= (Object.keys(attributes).length - 1) > index ? ',' : '' %> <% }) %> }, { + sequelize, + modelName: '<%= name %>', <%= underscored ? 'underscored: true,' : '' %> }); - <%= name %>.associate = function(models) { - // associations can be defined here - }; - return <%= name %>; }; diff --git a/src/assets/seeders/skeleton.js b/src/assets/seeders/skeleton.js index 989f2229..f1072a1f 100644 --- a/src/assets/seeders/skeleton.js +++ b/src/assets/seeders/skeleton.js @@ -1,26 +1,24 @@ 'use strict'; module.exports = { - up: (queryInterface, Sequelize) => { - /* - Add altering commands here. - Return a promise to correctly handle asynchronicity. - - Example: - return queryInterface.bulkInsert('People', [{ - name: 'John Doe', - isBetaMember: false - }], {}); + up: async (queryInterface, Sequelize) => { + /** + * Add seed commands here. + * + * Example: + * await queryInterface.bulkInsert('People', [{ + * name: 'John Doe', + * isBetaMember: false + * }], {}); */ }, - down: (queryInterface, Sequelize) => { - /* - Add reverting commands here. - Return a promise to correctly handle asynchronicity. - - Example: - return queryInterface.bulkDelete('People', null, {}); - */ + down: async (queryInterface, Sequelize) => { + /** + * Add commands to revert seed here. + * + * Example: + * await queryInterface.bulkDelete('People', null, {}); + */ } }; diff --git a/src/commands/model_generate.js b/src/commands/model_generate.js index 22fd5be3..c5ab75ee 100644 --- a/src/commands/model_generate.js +++ b/src/commands/model_generate.js @@ -30,7 +30,6 @@ exports.handler = function (args) { ensureMigrationsFolder(); checkModelFileExistence(args); - try { helpers.model.generateFile(args); } catch (err) { diff --git a/src/core/migrator.js b/src/core/migrator.js index 4783a810..f061f3c9 100644 --- a/src/core/migrator.js +++ b/src/core/migrator.js @@ -1,6 +1,5 @@ import Umzug from 'umzug'; import _ from 'lodash'; -import { promisify } from 'util'; import pTry from 'p-try'; import helpers from '../helpers/index'; @@ -34,10 +33,7 @@ function getSequelizeInstance () { export function getMigrator (type, args) { return pTry(() => { if (!(helpers.config.configFileExists() || args.url)) { - helpers.view.error( - 'Cannot find "' + helpers.config.getConfigFile() + - '". Have you run "sequelize init"?' - ); + helpers.view.error(`Cannot find "${helpers.config.getConfigFile()}". Have you run "sequelize init"?`); process.exit(1); } @@ -49,14 +45,7 @@ export function getMigrator (type, args) { migrations: { params: [sequelize.getQueryInterface(), Sequelize], path: helpers.path.getPath(type), - pattern: /\.c?js$/, - wrap: fun => { - if (fun.length === 3) { - return promisify(fun); - } else { - return fun; - } - } + pattern: /\.c?js$/ } }); diff --git a/src/sequelize.js b/src/sequelize.js index f5906e90..5db237e7 100644 --- a/src/sequelize.js +++ b/src/sequelize.js @@ -19,7 +19,7 @@ import helpers from './helpers/index'; helpers.view.teaser(); -const cli = yargs +yargs .help() .version() .command('db:migrate', 'Run pending migrations', migrate) @@ -42,11 +42,7 @@ const cli = yargs .command(['model:generate', 'model:create'], 'Generates a model and its migration', modelGenerate) .command(['seed:generate', 'seed:create'], 'Generates a new seed file', seedGenerate) .wrap(yargs.terminalWidth()) - .strict(); - -const args = cli.argv; - -// if no command then show help -if (!args._[0]) { - cli.showHelp(); -} + .demandCommand(1, 'Please specify a command') + .help() + .strict() + .argv; diff --git a/test/db/migrate-json.test.js b/test/db/migrate-json.test.js index f2b0d672..83ff0eab 100644 --- a/test/db/migrate-json.test.js +++ b/test/db/migrate-json.test.js @@ -111,8 +111,7 @@ const _ = require('lodash'); done(); }); }, { - migrationFile: 'new/*createPerson', - config: { promisifyMigrations: false } + migrationFile: 'new/*createPerson' }); }); }); diff --git a/test/db/migrate.test.js b/test/db/migrate.test.js index b0e7a905..2ef11f02 100644 --- a/test/db/migrate.test.js +++ b/test/db/migrate.test.js @@ -124,8 +124,7 @@ const _ = require('lodash'); done(); }); }, { - migrationFile: 'new/*createPerson', - config: { promisifyMigrations: false } + migrationFile: 'new/*createPerson' }); }); }); diff --git a/test/migration/create.test.js b/test/migration/create.test.js index af6718ce..97f87191 100644 --- a/test/migration/create.test.js +++ b/test/migration/create.test.js @@ -46,8 +46,8 @@ const gulp = require('gulp'); .src(Support.resolveSupportPath('tmp', 'migrations')) .pipe(helpers.readFile('*-' + migrationFile)) .pipe(helpers.expect(stdout => { - expect(stdout).to.contain('up: (queryInterface, Sequelize) => {'); - expect(stdout).to.contain('down: (queryInterface, Sequelize) => {'); + expect(stdout).to.contain('up: async (queryInterface, Sequelize) => {'); + expect(stdout).to.contain('down: async (queryInterface, Sequelize) => {'); })) .pipe(helpers.teardown(done)); }); diff --git a/test/model/create.test.js b/test/model/create.test.js index ca44c795..55566aaf 100644 --- a/test/model/create.test.js +++ b/test/model/create.test.js @@ -117,7 +117,7 @@ const _ = require('lodash'); gulp .src(Support.resolveSupportPath('tmp', 'models')) .pipe(helpers.readFile('user.js')) - .pipe(helpers.ensureContent('sequelize.define(\'User\'')) + .pipe(helpers.ensureContent('class User extends Model {')) .pipe(helpers.ensureContent('first_name: DataTypes.STRING')) .pipe(helpers.ensureContent('last_name: DataTypes.STRING')) .pipe(helpers.ensureContent('bio: DataTypes.TEXT')) @@ -160,7 +160,7 @@ const _ = require('lodash'); gulp .src(Support.resolveSupportPath('tmp', 'migrations')) .pipe(helpers.readFile('*-create-user.js')) - .pipe(helpers.ensureContent('return queryInterface')) + .pipe(helpers.ensureContent('await queryInterface')) .pipe(helpers.ensureContent('.createTable(\'Users\', {')) .pipe(helpers.ensureContent( 'first_name: {\n type: Sequelize.STRING\n },' @@ -209,9 +209,9 @@ const _ = require('lodash'); attributes }; - const targetContent = attrUnd.underscored ? - 'underscored: true' - : '{});'; + const targetContent = attrUnd.underscored + ? 'modelName: \'User\',\n underscored: true,\n });' + : 'modelName: \'User\',\n });'; if ( attrUnd.underscored ) { flags.underscored = attrUnd.underscored; @@ -224,7 +224,7 @@ const _ = require('lodash'); .src(Support.resolveSupportPath('tmp', 'models')) .pipe(helpers.readFile('user.js')) .pipe(helpers.ensureContent(targetContent)) - .pipe(helpers.ensureContent('.associate')) + .pipe(helpers.ensureContent('static associate')) .pipe(helpers.teardown(done)); }); }); diff --git a/test/seed/create.test.js b/test/seed/create.test.js index a856705a..c08bcd43 100644 --- a/test/seed/create.test.js +++ b/test/seed/create.test.js @@ -48,8 +48,8 @@ const gulp = require('gulp'); .src(Support.resolveSupportPath('tmp', 'seeders')) .pipe(helpers.readFile('*-' + seedFile)) .pipe(helpers.expect(stdout => { - expect(stdout).to.contain('up: (queryInterface, Sequelize) => {'); - expect(stdout).to.contain('down: (queryInterface, Sequelize) => {'); + expect(stdout).to.contain('up: async (queryInterface, Sequelize) => {'); + expect(stdout).to.contain('down: async (queryInterface, Sequelize) => {'); })) .pipe(helpers.teardown(done)); }); diff --git a/test/support/assets/migrations/20111117063700-createPerson.js b/test/support/assets/migrations/20111117063700-createPerson.js index 63d179f4..047cb9c8 100644 --- a/test/support/assets/migrations/20111117063700-createPerson.js +++ b/test/support/assets/migrations/20111117063700-createPerson.js @@ -1,21 +1,18 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration - .createTable('Person', { - name: DataTypes.STRING, - isBetaMember: { - type: DataTypes.BOOLEAN, - defaultValue: false, - allowNull: false - } - }), done); + up: function (migration, DataTypes) { + return migration.createTable("Person", { + name: DataTypes.STRING, + isBetaMember: { + type: DataTypes.BOOLEAN, + defaultValue: false, + allowNull: false, + }, + }); }, - down: function (migration, DataTypes, done) { - nodeify(migration.dropTable('Person'), done); - } + down: function (migration, DataTypes) { + return migration.dropTable("Person"); + }, }; diff --git a/test/support/assets/migrations/20111130161100-emptyMigration.js b/test/support/assets/migrations/20111130161100-emptyMigration.js index e4594838..66a15f1f 100644 --- a/test/support/assets/migrations/20111130161100-emptyMigration.js +++ b/test/support/assets/migrations/20111130161100-emptyMigration.js @@ -1,10 +1,6 @@ -'use strict'; +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - done(); - }, - down: function (migration, DataTypes, done) { - done(); - } + up: async function (migration, DataTypes) {}, + down: async function (migration, DataTypes) {}, }; diff --git a/test/support/assets/migrations/20111205064000-renamePersonToUser.js b/test/support/assets/migrations/20111205064000-renamePersonToUser.js index b435a919..752f63df 100644 --- a/test/support/assets/migrations/20111205064000-renamePersonToUser.js +++ b/test/support/assets/migrations/20111205064000-renamePersonToUser.js @@ -1,13 +1,11 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.renameTable('Person', 'User'), done); + up: function (migration, DataTypes) { + return migration.renameTable("Person", "User"); }, - down: function (migration, DataTypes, done) { - nodeify(migration.renameTable('User', 'Person'), done); - } + down: function (migration, DataTypes) { + return migration.renameTable("User", "Person"); + }, }; diff --git a/test/support/assets/migrations/20111205162700-addSignatureColumnToUser.js b/test/support/assets/migrations/20111205162700-addSignatureColumnToUser.js index 92e54fe6..7651bfc2 100644 --- a/test/support/assets/migrations/20111205162700-addSignatureColumnToUser.js +++ b/test/support/assets/migrations/20111205162700-addSignatureColumnToUser.js @@ -1,50 +1,22 @@ -'use strict'; +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - migration - .addColumn('User', 'isAdmin', { - type: DataTypes.BOOLEAN, - defaultValue: false, - allowNull: false - }) - .done(function (err) { - if (err) { - done(err); - } else { - migration - .addColumn('User', 'signature', DataTypes.TEXT) - .done(function (err) { - if (err) { - done(err); - } else { - migration.addColumn('User', 'shopId', { - type: DataTypes.INTEGER, - allowNull: true - }).done(function () { - done(); - }); - } - }); - } - }); + up: async function (migration, DataTypes) { + await migration.addColumn("User", "isAdmin", { + type: DataTypes.BOOLEAN, + defaultValue: false, + allowNull: false, + }); + await migration.addColumn("User", "signature", DataTypes.TEXT); + await migration.addColumn("User", "shopId", { + type: DataTypes.INTEGER, + allowNull: true, + }); }, - down: function (migration, DataTypes, done) { - migration.removeColumn('User', 'signature').done(function (err) { - if (err) { - done(err); - } else { - migration.removeColumn('User', 'shopId').done(function (err) { - if (err) { - done(err); - } else { - migration.removeColumn('User', 'isAdmin').done(function () { - done(); - }); - } - }); - } - }); - } + down: async function (migration, DataTypes) { + await migration.removeColumn("User", "signature"); + await migration.removeColumn("User", "shopId"); + await migration.removeColumn("User", "isAdmin"); + }, }; diff --git a/test/support/assets/migrations/20111205167000-addUniqueNameColumnToUser.js b/test/support/assets/migrations/20111205167000-addUniqueNameColumnToUser.js index ed569c4e..84d0ae2b 100644 --- a/test/support/assets/migrations/20111205167000-addUniqueNameColumnToUser.js +++ b/test/support/assets/migrations/20111205167000-addUniqueNameColumnToUser.js @@ -1,25 +1,16 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify( - migration.addColumn('User', 'uniqueName', { type: DataTypes.STRING }), - function () { - nodeify( - migration.changeColumn('User', 'uniqueName', { - type: DataTypes.STRING, - allowNull: false, - unique: true - }), - done - ); - } - ); + up: async function (migration, DataTypes) { + await migration.addColumn("User", "uniqueName", { type: DataTypes.STRING }); + await migration.changeColumn("User", "uniqueName", { + type: DataTypes.STRING, + allowNull: false, + unique: true, + }); }, - down: function (migration, DataTypes, done) { - nodeify(migration.removeColumn('User', 'uniqueName'), done); - } + down: async function (migration, DataTypes) { + await migration.removeColumn("User", "uniqueName"); + }, }; diff --git a/test/support/assets/migrations/20111206061400-removeShopIdColumnFromUser.js b/test/support/assets/migrations/20111206061400-removeShopIdColumnFromUser.js index f62d4b56..51fe5dab 100644 --- a/test/support/assets/migrations/20111206061400-removeShopIdColumnFromUser.js +++ b/test/support/assets/migrations/20111206061400-removeShopIdColumnFromUser.js @@ -1,16 +1,13 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.removeColumn('User', 'shopId'), done); + up: function (migration, DataTypes) { + return migration.removeColumn("User", "shopId"); }, - - down: function (migration, DataTypes, done) { - nodeify(migration.addColumn('User', 'shopId', { + down: function (migration, DataTypes) { + return migration.addColumn("User", "shopId", { type: DataTypes.INTEGER, - allowNull: true - }), done); - } + allowNull: true, + }); + }, }; diff --git a/test/support/assets/migrations/20111206063000-changeSignatureColumnOfUserToMendatory.js b/test/support/assets/migrations/20111206063000-changeSignatureColumnOfUserToMendatory.js index 93a96c23..ebf4392a 100644 --- a/test/support/assets/migrations/20111206063000-changeSignatureColumnOfUserToMendatory.js +++ b/test/support/assets/migrations/20111206063000-changeSignatureColumnOfUserToMendatory.js @@ -1,17 +1,13 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.changeColumn('User', 'signature', { + up: function (migration, DataTypes) { + return migration.changeColumn("User", "signature", { type: DataTypes.STRING, allowNull: false, - defaultValue: 'Signature' - }), done); + defaultValue: "Signature", + }); }, - down: function (migration, DataTypes, done) { - done(); - } + down: function (migration, DataTypes) {}, }; diff --git a/test/support/assets/migrations/20111206163300-renameSignatureColumnOfUserToSig.js b/test/support/assets/migrations/20111206163300-renameSignatureColumnOfUserToSig.js index 5b44f90c..1d08a0c2 100644 --- a/test/support/assets/migrations/20111206163300-renameSignatureColumnOfUserToSig.js +++ b/test/support/assets/migrations/20111206163300-renameSignatureColumnOfUserToSig.js @@ -1,13 +1,11 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.renameColumn('User', 'signature', 'sig'), done); + up: function (migration, DataTypes) { + return migration.renameColumn("User", "signature", "sig"); }, - down: function (migration, DataTypes, done) { - nodeify(migration.renameColumn('User', 'sig', 'signature'), done); - } + down: function (migration, DataTypes) { + return migration.renameColumn("User", "sig", "signature"); + }, }; diff --git a/test/support/assets/migrations/20130909174103-createFunctionGetAnAnswer.js b/test/support/assets/migrations/20130909174103-createFunctionGetAnAnswer.js index 0543a033..bd86250d 100644 --- a/test/support/assets/migrations/20130909174103-createFunctionGetAnAnswer.js +++ b/test/support/assets/migrations/20130909174103-createFunctionGetAnAnswer.js @@ -1,12 +1,16 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.createFunction('get_an_answer', [], 'int', 'plpgsql', 'RETURN 42;'), done); + up: function (migration, DataTypes) { + return migration.createFunction( + "get_an_answer", + [], + "int", + "plpgsql", + "RETURN 42;" + ); + }, + down: function (migration, DataTypes) { + return migration.dropFunction("get_an_answer", []); }, - down: function (migration, DataTypes, done) { - nodeify(migration.dropFunction('get_an_answer', []), done); - } }; diff --git a/test/support/assets/migrations/20130909174253-renameFunctionGetAnAnswerGetTheAnswer.js b/test/support/assets/migrations/20130909174253-renameFunctionGetAnAnswerGetTheAnswer.js index c66c224c..87cc1986 100644 --- a/test/support/assets/migrations/20130909174253-renameFunctionGetAnAnswerGetTheAnswer.js +++ b/test/support/assets/migrations/20130909174253-renameFunctionGetAnAnswerGetTheAnswer.js @@ -1,12 +1,10 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.renameFunction('get_an_answer', [], 'get_the_answer'), done); + up: function (migration, DataTypes) { + return igration.renameFunction("get_an_answer", [], "get_the_answer"); + }, + down: function (migration, DataTypes) { + return migration.renameFunction("get_the_answer", [], "get_an_answer"); }, - down: function (migration, DataTypes, done) { - nodeify(migration.renameFunction('get_the_answer', [], 'get_an_answer'), done); - } }; diff --git a/test/support/assets/migrations/20130909175000-deleteFunctionGetTheAnswer.js b/test/support/assets/migrations/20130909175000-deleteFunctionGetTheAnswer.js index 661ec614..31cd4b0a 100644 --- a/test/support/assets/migrations/20130909175000-deleteFunctionGetTheAnswer.js +++ b/test/support/assets/migrations/20130909175000-deleteFunctionGetTheAnswer.js @@ -1,12 +1,15 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.dropFunction('get_the_answer', []), done); + up: function (migration, DataTypes) { + return migration.dropFunction("get_the_answer", []); + }, + down: function (migration, DataTypes) { + return migration.createFunction( + "get_the_answer", + "int", + "plpgsql", + "RETURN 42;" + ); }, - down: function (migration, DataTypes, done) { - nodeify(migration.createFunction('get_the_answer', 'int', 'plpgsql', 'RETURN 42;'), done); - } }; diff --git a/test/support/assets/migrations/20130909175939-createTestTableForTrigger.js b/test/support/assets/migrations/20130909175939-createTestTableForTrigger.js index 3131298a..897b11c5 100644 --- a/test/support/assets/migrations/20130909175939-createTestTableForTrigger.js +++ b/test/support/assets/migrations/20130909175939-createTestTableForTrigger.js @@ -1,23 +1,18 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify( - migration.createTable('trigger_test', { - name: DataTypes.STRING, - updated_at: { - type: DataTypes.DATE, - defaultValue: DataTypes.NOW, - allowNull: false - } - }), - done - ); + up: function (migration, DataTypes) { + return migration.createTable("trigger_test", { + name: DataTypes.STRING, + updated_at: { + type: DataTypes.DATE, + defaultValue: DataTypes.NOW, + allowNull: false, + }, + }); }, - down: function (migration, DataTypes, done) { - nodeify(migration.dropTable('trigger_test'), done); - } + down: function (migration, DataTypes) { + return migration.dropTable("trigger_test"); + }, }; diff --git a/test/support/assets/migrations/20130909180846-createTriggerOnTriggerTestTable.js b/test/support/assets/migrations/20130909180846-createTriggerOnTriggerTestTable.js index b738b7cb..92a68c8a 100644 --- a/test/support/assets/migrations/20130909180846-createTriggerOnTriggerTestTable.js +++ b/test/support/assets/migrations/20130909180846-createTriggerOnTriggerTestTable.js @@ -1,22 +1,17 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify( - migration.createTrigger( - 'trigger_test', - 'updated_at', - 'before', - { update: true }, - 'bump_updated_at', - [] - ), - done + up: function (migration, DataTypes) { + return migration.createTrigger( + "trigger_test", + "updated_at", + "before", + { update: true }, + "bump_updated_at", + [] ); }, - down: function (migration, DataTypes, done) { - nodeify(migration.dropTrigger('trigger_test', 'updated_at'), done); - } + down: function (migration, DataTypes) { + return migration.dropTrigger("trigger_test", "updated_at"); + }, }; diff --git a/test/support/assets/migrations/20130909181148-renameTriggerUpdatedAtToUpdateUpdatedAt.js b/test/support/assets/migrations/20130909181148-renameTriggerUpdatedAtToUpdateUpdatedAt.js index 858e95bc..47987c53 100644 --- a/test/support/assets/migrations/20130909181148-renameTriggerUpdatedAtToUpdateUpdatedAt.js +++ b/test/support/assets/migrations/20130909181148-renameTriggerUpdatedAtToUpdateUpdatedAt.js @@ -1,12 +1,18 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.renameTrigger('trigger_test', 'updated_at', 'update_updated_at'), done); + up: function (migration, DataTypes) { + return migration.renameTrigger( + "trigger_test", + "updated_at", + "update_updated_at" + ); + }, + down: function (migration, DataTypes) { + return migration.renameTrigger( + "trigger_test", + "update_updated_at", + "updated_at" + ); }, - down: function (migration, DataTypes, done) { - nodeify(migration.renameTrigger('trigger_test', 'update_updated_at', 'updated_at'), done); - } }; diff --git a/test/support/assets/migrations/20130909185621-deleteTriggerUpdateUpdatedAt.js b/test/support/assets/migrations/20130909185621-deleteTriggerUpdateUpdatedAt.js index 437495b8..47a2f88d 100644 --- a/test/support/assets/migrations/20130909185621-deleteTriggerUpdateUpdatedAt.js +++ b/test/support/assets/migrations/20130909185621-deleteTriggerUpdateUpdatedAt.js @@ -1,23 +1,18 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.dropTrigger('trigger_test', 'update_updated_at'), done); + up: function (migration, DataTypes) { + return migration.dropTrigger("trigger_test", "update_updated_at"); }, - down: function (migration, DataTypes, done) { - nodeify( - migration.createTrigger( - 'trigger_test', - 'update_updated_at', - 'before', - { update: true }, - 'bump_updated_at', - [] - ), - done + down: function (migration, DataTypes) { + return migration.createTrigger( + "trigger_test", + "update_updated_at", + "before", + { update: true }, + "bump_updated_at", + [] ); - } + }, }; diff --git a/test/support/assets/migrations/20170526153000-createPost.js b/test/support/assets/migrations/20170526153000-createPost.js index d8d844b3..11e4007c 100644 --- a/test/support/assets/migrations/20170526153000-createPost.js +++ b/test/support/assets/migrations/20170526153000-createPost.js @@ -1,17 +1,14 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration - .createTable('Post', { - title: DataTypes.STRING, - body: DataTypes.TEXT - }), done); + up: function (migration, DataTypes) { + return migration.createTable("Post", { + title: DataTypes.STRING, + body: DataTypes.TEXT, + }); }, - down: function (migration, DataTypes, done) { - nodeify(migration.dropTable('Post'), done); - } + down: function (migration, DataTypes) { + return migration.dropTable("Post"); + }, }; diff --git a/test/support/assets/migrations/cjs/20200617063700-createComment.cjs b/test/support/assets/migrations/cjs/20200617063700-createComment.cjs index 7f6255c3..71989af5 100644 --- a/test/support/assets/migrations/cjs/20200617063700-createComment.cjs +++ b/test/support/assets/migrations/cjs/20200617063700-createComment.cjs @@ -1,17 +1,13 @@ 'use strict'; -var nodeify = require('nodeify'); - module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration - .createTable('Comment', { - title: DataTypes.STRING, - body: DataTypes.TEXT - }), done); + up: async (queryInterface, DataTypes) => { + await queryInterface.createTable('Comment', { + title: DataTypes.STRING, + body: DataTypes.TEXT + }); }, - - down: function (migration, DataTypes, done) { - nodeify(migration.dropTable('Comment'), done); + down: async (queryInterface, DataTypes) => { + await queryInterface.dropTable('Comment'); } }; diff --git a/test/support/assets/migrations/invalid/20141208213500-createPerson.js b/test/support/assets/migrations/invalid/20141208213500-createPerson.js index 68a10ffa..365a31e4 100644 --- a/test/support/assets/migrations/invalid/20141208213500-createPerson.js +++ b/test/support/assets/migrations/invalid/20141208213500-createPerson.js @@ -1,13 +1,10 @@ 'use strict'; -var Bluebird = require('bluebird'); +const Bluebird = require('bluebird'); module.exports = { - up: function (db) { - return Bluebird - .delay(1) - .then(function () { - return db.sequelize.query('INVALID QUERY'); - }); + up: async (queryInterface) => { + await Bluebird.delay(1); + await queryInterface.sequelize.query('INVALID QUERY'); } }; diff --git a/test/support/assets/migrations/new/20141208213500-createPerson.js b/test/support/assets/migrations/new/20141208213500-createPerson.js index dc1c8160..7e8640ef 100644 --- a/test/support/assets/migrations/new/20141208213500-createPerson.js +++ b/test/support/assets/migrations/new/20141208213500-createPerson.js @@ -4,14 +4,9 @@ var Bluebird = require('bluebird'); var Sequelize = require('sequelize'); module.exports = { - up: function (db) { - return Bluebird - .delay(1) - .then(function () { - return db.createTable('Person', { name: Sequelize.STRING }); - }) - .then(function () { - return db.createTable('Task', { title: Sequelize.STRING }); - }); + up: async (queryInterface) => { + await Bluebird.delay(1); + await queryInterface.createTable('Person', { name: Sequelize.STRING }); + await queryInterface.createTable('Task', { title: Sequelize.STRING }); } }; diff --git a/test/support/assets/seeders/20111117063700-seedPerson.js b/test/support/assets/seeders/20111117063700-seedPerson.js index fa6c19e1..276fa0cf 100644 --- a/test/support/assets/seeders/20111117063700-seedPerson.js +++ b/test/support/assets/seeders/20111117063700-seedPerson.js @@ -1,18 +1,15 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration.bulkInsert('Person', [{ - name: 'John Doe', - isBetaMember: false - }], { - name: {}, - isBetaMember: {} - }), done); + up: function (migration, DataTypes) { + return migration.bulkInsert("Person", [ + { + name: "John Doe", + isBetaMember: false, + }, + ]); + }, + down: function (migration, DataTypes) { + return migration.bulkDelete("Person", null, {}); }, - down: function (migration, DataTypes, done) { - nodeify(migration.bulkDelete('Person', null, {}), done); - } }; diff --git a/test/support/assets/seeders/20111117063900-seedPerson2.js b/test/support/assets/seeders/20111117063900-seedPerson2.js index 0833991f..592e0f10 100644 --- a/test/support/assets/seeders/20111117063900-seedPerson2.js +++ b/test/support/assets/seeders/20111117063900-seedPerson2.js @@ -1,19 +1,15 @@ -'use strict'; - -var nodeify = require('nodeify'); +"use strict"; module.exports = { - up: function (migration, DataTypes, done) { - nodeify(migration - .bulkInsert('Person', [{ - name: 'Jane Doe', - isBetaMember: false - }], { - name: {}, - isBetaMember: {} - }), done); + up: function (migration, DataTypes) { + return migration.bulkInsert("Person", [ + { + name: "Jane Doe", + isBetaMember: false, + }, + ]); + }, + down: function (migration, DataTypes) { + return migration.bulkDelete("Person", null, {}); }, - down: function (migration, DataTypes, done) { - nodeify(migration.bulkDelete('Person', null, {}), done); - } }; diff --git a/test/support/assets/seeders/new/20141208213500-seedPerson.js b/test/support/assets/seeders/new/20141208213500-seedPerson.js index b2cb8e97..f484118c 100644 --- a/test/support/assets/seeders/new/20141208213500-seedPerson.js +++ b/test/support/assets/seeders/new/20141208213500-seedPerson.js @@ -1,16 +1,17 @@ -'use strict'; +"use strict"; -var Bluebird = require('bluebird'); +var Bluebird = require("bluebird"); module.exports = { up: function (db) { - return Bluebird - .delay(1) + return Bluebird.delay(1) .then(function () { - return db.bulkInsert('Person', [{ name: 'John Doe' }], { name: {} }); + return db.bulkInsert("Person", [{ name: "John Doe" }], { name: {} }); }) .then(function () { - return db.insert('Task', [{ title: 'Find own identity' }], { name: {} }); + return db.insert("Task", [{ title: "Find own identity" }], { + name: {}, + }); }); - } + }, };