knex-migrator 5.1.4 → 5.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2022 Ghost Foundation
1
+ Copyright (c) 2013-2023 Ghost Foundation
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -126,7 +126,6 @@ module.exports.config = {
126
126
 
127
127
  ### Examples
128
128
  ```
129
- const Promise = require('bluebird');
130
129
 
131
130
  module.exports.up = function(options) {
132
131
  const connection = options.connection;
@@ -146,7 +145,6 @@ module.exports.down = function(options) {
146
145
  ```
147
146
 
148
147
  ```
149
- const Promise = require('bluebird');
150
148
 
151
149
  module.exports.config = {
152
150
  transaction: true
@@ -338,7 +336,7 @@ knexMigrator.isDatabaseOK()
338
336
 
339
337
  # Copyright & License
340
338
 
341
- Copyright (c) 2013-2022 Ghost Foundation - Released under the [MIT license](LICENSE).
339
+ Copyright (c) 2013-2023 Ghost Foundation - Released under the [MIT license](LICENSE).
342
340
 
343
341
 
344
342
 
package/lib/database.js CHANGED
@@ -1,9 +1,9 @@
1
1
  const knex = require('knex'),
2
- Promise = require('bluebird'),
3
2
  omit = require('lodash/omit'),
4
3
  debug = require('debug')('knex-migrator:database'),
5
4
  errors = require('./errors');
6
5
  const DatabaseInfo = require('@tryghost/database-info');
6
+ const {sequence} = require('@tryghost/promise');
7
7
 
8
8
  /**
9
9
  * @NOTE: Knex-migrator only supports knex query builder.
@@ -41,7 +41,7 @@ exports.connect = function connect(options) {
41
41
  * This helper functions is used to test the connection. It's basically a "test query".
42
42
  *
43
43
  * @param connection
44
- * @returns {Bluebird<R> | Bluebird<any> | Promise<T>}
44
+ * @returns {Promise<R> | Promise<any> | Promise<T>}
45
45
  */
46
46
  exports.ensureConnectionWorks = (connection) => {
47
47
  return connection.raw('SELECT 1+1 as RESULT;')
@@ -76,7 +76,7 @@ module.exports.createTransaction = function (connection, callback) {
76
76
  *
77
77
  * @TODO: https://github.com/TryGhost/knex-migrator/issues/118
78
78
  * @TODO: https://github.com/TryGhost/knex-migrator/issues/91
79
- * @returns {Bluebird<R> | Bluebird<any> | * | Promise<T>}
79
+ * @returns {Promise<R> | Promise<any> | * | Promise<T>}
80
80
  */
81
81
  exports.createMigrationsTable = async function createMigrationsTable(connection) {
82
82
  const hasTable = await connection.schema.hasTable('migrations');
@@ -182,7 +182,7 @@ exports.drop = function drop(options) {
182
182
  // @NOTE: We cannot just remove the sqlite3 file, because any database connection will get invalid.
183
183
  return connection.raw('SELECT name FROM sqlite_master WHERE type="table";')
184
184
  .then(function (tables) {
185
- return Promise.each(tables, function (table) {
185
+ return sequence(tables.map(table => () => {
186
186
  if (table.name === 'sqlite_sequence') {
187
187
  debug('Skip drop table: ' + table.name);
188
188
  return Promise.resolve();
@@ -190,7 +190,7 @@ exports.drop = function drop(options) {
190
190
 
191
191
  debug('Drop table: ' + table.name);
192
192
  return connection.schema.dropTableIfExists(table.name);
193
- });
193
+ }));
194
194
  })
195
195
  .catch(function (err) {
196
196
  // CASE: database file was never initialised
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const _ = require('lodash');
2
2
  const path = require('path');
3
- const Promise = require('bluebird');
3
+ const {sequence} = require('@tryghost/promise');
4
4
  const debug = require('debug')('knex-migrator:index');
5
5
  const database = require('./database');
6
6
  const utils = require('./utils');
@@ -60,7 +60,7 @@ function KnexMigrator(options = {}) {
60
60
  * otherwise we would overjump migration files to execute.
61
61
  *
62
62
  * @param {Object} options - Custom options you can pass in (disableHooks, noScripts, skipInitCompletion, only, skip)
63
- * @returns {Bluebird<R>}
63
+ * @returns {Promise<R>}
64
64
  */
65
65
  KnexMigrator.prototype.init = function init(options) {
66
66
  options = options || {};
@@ -264,9 +264,9 @@ KnexMigrator.prototype.init = function init(options) {
264
264
  });
265
265
  });
266
266
 
267
- return Promise.each(ops, function (op) {
267
+ return sequence(ops.map(op => () => {
268
268
  return op.bind(self)();
269
- });
269
+ }));
270
270
  });
271
271
  };
272
272
 
@@ -287,7 +287,7 @@ KnexMigrator.prototype.init = function init(options) {
287
287
  * 8. Disconnect from database otherwise the CLI won't close properly.
288
288
  *
289
289
  * @param {Object} options - Custom options you can pass in (version, force, init, only, skip)
290
- * @returns {Bluebird<any>}
290
+ * @returns {Promise<any>}
291
291
  */
292
292
  KnexMigrator.prototype.migrate = async function migrate(options) {
293
293
  options = options || {};
@@ -559,7 +559,7 @@ KnexMigrator.prototype.reset = function reset(options) {
559
559
  * 6. Returns result.
560
560
  * 7. Destroy connection.
561
561
  *
562
- * @returns {Bluebird<any>}
562
+ * @returns {Promise<any>}
563
563
  */
564
564
  KnexMigrator.prototype.isDatabaseOK = function isDatabaseOK() {
565
565
  let self = this;
@@ -642,7 +642,7 @@ KnexMigrator.prototype.isDatabaseOK = function isDatabaseOK() {
642
642
  * 7. Destroy connection.
643
643
  *
644
644
  * @param {Object} options - Custom options the user can pass in (force, version, v, disableHooks)
645
- * @returns {Bluebird<any>}
645
+ * @returns {Promise<any>}
646
646
  */
647
647
  KnexMigrator.prototype.rollback = function rollback(options) {
648
648
  options = options || {};
@@ -715,12 +715,12 @@ KnexMigrator.prototype.rollback = function rollback(options) {
715
715
  });
716
716
 
717
717
  values.reverse();
718
- return Promise.each(values, function (value) {
718
+ return sequence(values.map(value => () => {
719
719
  return self._rollback({
720
720
  version: value.version,
721
721
  onlyTasks: [value.name]
722
722
  });
723
- });
723
+ }));
724
724
  });
725
725
  }).then(function () {
726
726
  if (hooks.shutdown) {
@@ -788,7 +788,7 @@ KnexMigrator.prototype.rollback = function rollback(options) {
788
788
  * 3. Delete migration entry from database.
789
789
  *
790
790
  * @param {Object} options - Custom options the user can pass in (version, skippedTasks, onlyTasks, task)
791
- * @returns {Bluebird<IterableOrNever<R>>}
791
+ * @returns {Promise<IterableOrNever<R>>}
792
792
  * @private
793
793
  */
794
794
  KnexMigrator.prototype._rollback = function _rollback(options) {
@@ -858,7 +858,7 @@ KnexMigrator.prototype._rollback = function _rollback(options) {
858
858
 
859
859
  tasks.reverse();
860
860
 
861
- return Promise.each(tasks, function (task) {
861
+ return sequence(tasks.map(task => () => {
862
862
  if (skippedTasks[version] && skippedTasks[version].indexOf(task.name) !== -1) {
863
863
  return Promise.resolve();
864
864
  }
@@ -905,7 +905,7 @@ KnexMigrator.prototype._rollback = function _rollback(options) {
905
905
  })
906
906
  .delete();
907
907
  });
908
- });
908
+ }));
909
909
  };
910
910
 
911
911
  /**
@@ -924,7 +924,7 @@ KnexMigrator.prototype._rollback = function _rollback(options) {
924
924
  * 5. Returns any skipped task. Skipped tasks are tasks which failed. Only one task is returned, the last one which failed.
925
925
  *
926
926
  * @param {Object} options - Custom options the user can pass in (version, hooks, only, skip)
927
- * @returns {Bluebird<{skippedTasks: Array}>}
927
+ * @returns {Promise<{skippedTasks: Array}>}
928
928
  * @private
929
929
  */
930
930
  KnexMigrator.prototype._migrateTo = function _migrateTo(options) {
@@ -964,7 +964,7 @@ KnexMigrator.prototype._migrateTo = function _migrateTo(options) {
964
964
  debug('Migrate: ' + version + ' with ' + tasks.length + ' tasks.');
965
965
  debug('Tasks: ' + JSON.stringify(tasks));
966
966
 
967
- return Promise.each(tasks, function executeTask(task) {
967
+ return sequence(tasks.map(task => () => {
968
968
  return self._beforeEach({
969
969
  task: task.name,
970
970
  version: version
@@ -1036,7 +1036,7 @@ KnexMigrator.prototype._migrateTo = function _migrateTo(options) {
1036
1036
  err: err
1037
1037
  });
1038
1038
  });
1039
- }).then(function () {
1039
+ })).then(function () {
1040
1040
  return {
1041
1041
  skippedTasks: skippedTasks
1042
1042
  };
@@ -1099,7 +1099,7 @@ KnexMigrator.prototype._afterEach = function _afterEach(options) {
1099
1099
  * database. It returns expected and actual database state.
1100
1100
  *
1101
1101
  * @param {Object} options - Custom user options (force)
1102
- * @returns {Bluebird<any>}
1102
+ * @returns {Promise<any>}
1103
1103
  * @private
1104
1104
  */
1105
1105
  KnexMigrator.prototype._integrityCheck = async function _integrityCheck(options) {
package/lib/locking.js CHANGED
@@ -50,7 +50,7 @@ module.exports.lock = function (connection) {
50
50
 
51
51
  /**
52
52
  * @description Private helper to determine whether the database is locked or not.
53
- * @returns {Bluebird<boolean>}
53
+ * @returns {boolean}
54
54
  */
55
55
  module.exports.isLocked = function (connection) {
56
56
  return connection('migrations_lock')
package/lib/utils.js CHANGED
@@ -2,8 +2,7 @@ const path = require('path'),
2
2
  _ = require('lodash'),
3
3
  fs = require('fs'),
4
4
  compareVer = require('compare-ver'),
5
- Promise = require('bluebird'),
6
- resolve = Promise.promisify(require('resolve')),
5
+ resolve = require('util').promisify(require('resolve')),
7
6
  debug = require('debug')('knex-migrator:utils'),
8
7
  errors = require('./errors');
9
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knex-migrator",
3
- "version": "5.1.4",
3
+ "version": "5.1.6",
4
4
  "description": "Database migrations with knex.",
5
5
  "keywords": [
6
6
  "ghost",
@@ -47,10 +47,10 @@
47
47
  "node": "^14.18.0 || ^16.13.0 || ^18.12.1"
48
48
  },
49
49
  "dependencies": {
50
- "@tryghost/database-info": "0.3.17",
51
- "@tryghost/errors": "1.2.24",
52
- "@tryghost/logging": "2.4.4",
53
- "bluebird": "3.7.2",
50
+ "@tryghost/database-info": "0.3.21",
51
+ "@tryghost/errors": "1.2.27",
52
+ "@tryghost/logging": "2.4.9",
53
+ "@tryghost/promise": "0.3.4",
54
54
  "commander": "5.1.0",
55
55
  "compare-ver": "2.0.2",
56
56
  "debug": "4.3.4",
@@ -58,8 +58,8 @@
58
58
  "lodash": "4.17.21",
59
59
  "moment": "2.24.0",
60
60
  "mysql2": "3.2.0",
61
- "nconf": "0.12.0",
62
- "resolve": "1.22.3"
61
+ "nconf": "0.12.1",
62
+ "resolve": "1.22.8"
63
63
  },
64
64
  "files": [
65
65
  "bin",