knex-migrator 4.2.10 → 5.0.1

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/lib/errors.js CHANGED
@@ -1,84 +1,83 @@
1
- const util = require('util');
2
- const each = require('lodash/each');
3
- const errors = require('ghost-ignition').errors;
1
+ const errors = require('@tryghost/errors');
2
+ const merge = require('lodash/merge');
4
3
 
5
- function KnexMigrateError(options) {
6
- options = options || {};
7
- errors.IgnitionError.call(this, options);
8
- }
4
+ class KnexMigrateError extends errors.MigrationError {}
9
5
 
10
6
  const knexMigratorErrors = {
11
- MigrationExistsError: function MigrationExistsError(options) {
12
- KnexMigrateError.call(this, Object.assign({
13
- id: 100,
14
- errorType: 'MigrationExistsError'
15
- }, options));
7
+ MigrationExistsError: class MigrationExistsError extends KnexMigrateError {
8
+ constructor(options) {
9
+ super(merge({
10
+ id: 100,
11
+ errorType: 'MigrationExistsError'
12
+ }, options));
13
+ }
16
14
  },
17
- DatabaseIsNotOkError: function DatabaseIsNotOkError(options) {
18
- KnexMigrateError.call(this, Object.assign({
19
- id: 200,
20
- errorType: 'DatabaseIsNotOkError',
21
- help: 'If knex-migrator is not installed, please run "npm install -g knex-migrator" \nRead more here: https://github.com/TryGhost/knex-migrator'
22
- }, options));
15
+ DatabaseIsNotOkError: class DatabaseIsNotOkError extends KnexMigrateError {
16
+ constructor(options) {
17
+ super(merge({
18
+ id: 200,
19
+ errorType: 'DatabaseIsNotOkError',
20
+ help: 'If knex-migrator is not installed, please run "npm install -g knex-migrator" \nRead more here: https://github.com/TryGhost/knex-migrator'
21
+ }, options));
22
+ }
23
23
  },
24
- MigrationScriptError: function MigrationScriptError(options) {
25
- KnexMigrateError.call(this, Object.assign({
26
- id: 300,
27
- errorType: 'MigrationScriptError'
28
- }, options));
24
+ MigrationScriptError: class MigrationScriptError extends KnexMigrateError {
25
+ constructor(options) {
26
+ super(merge({
27
+ id: 300,
28
+ errorType: 'MigrationScriptError'
29
+ }, options));
30
+ }
29
31
  },
30
- RollbackError: function RollbackError(options) {
31
- KnexMigrateError.call(this, Object.assign({
32
- id: 400,
33
- errorType: 'RollbackError'
34
- }, options));
32
+ RollbackError: class RollbackError extends KnexMigrateError {
33
+ constructor(options) {
34
+ super(merge({
35
+ id: 400,
36
+ errorType: 'RollbackError'
37
+ }, options));
38
+ }
35
39
  },
36
- MigrationsAreLockedError: function MigrationsAreLockedError(options) {
37
- KnexMigrateError.call(this, Object.assign({
38
- id: 500,
39
- errorType: 'MigrationsAreLockedError'
40
- }, options));
40
+ MigrationsAreLockedError: class MigrationsAreLockedError extends KnexMigrateError {
41
+ constructor(options) {
42
+ super(merge({
43
+ id: 500,
44
+ errorType: 'MigrationsAreLockedError'
45
+ }, options));
46
+ }
41
47
  },
42
- LockError: function LockError(options) {
43
- KnexMigrateError.call(this, Object.assign({
44
- id: 500,
45
- errorType: 'LockError'
46
- }, options));
48
+ LockError: class LockError extends KnexMigrateError {
49
+ constructor(options) {
50
+ super(merge({
51
+ id: 500,
52
+ errorType: 'LockError'
53
+ }, options));
54
+ }
47
55
  },
48
- UnlockError: function UnlockError(options) {
49
- KnexMigrateError.call(this, Object.assign({
50
- id: 500,
51
- errorType: 'UnlockError'
52
- }, options));
56
+ UnlockError: class UnlockError extends KnexMigrateError {
57
+ constructor(options) {
58
+ super(merge({
59
+ id: 500,
60
+ errorType: 'UnlockError'
61
+ }, options));
62
+ }
53
63
  },
54
- DatabaseError: function DatabaseError(options) {
55
- KnexMigrateError.call(this, Object.assign({
56
- id: 500,
57
- errorType: 'DatabaseError'
58
- }, options));
64
+ DatabaseError: class DatabaseError extends KnexMigrateError {
65
+ constructor(options) {
66
+ super(merge({
67
+ id: 500,
68
+ errorType: 'DatabaseError'
69
+ }, options));
70
+ }
59
71
  },
60
- IrreversibleMigrationError: function IrreversibleMigrationError(options) {
61
- KnexMigrateError.call(this, Object.assign({
62
- id: 500,
63
- errorType: 'IrreversibleMigrationError'
64
- }, options));
72
+ IrreversibleMigrationError: class IrreversibleMigrationError extends KnexMigrateError {
73
+ constructor(options) {
74
+ super(merge({
75
+ id: 500,
76
+ errorType: 'IrreversibleMigrationError'
77
+ }, options));
78
+ }
65
79
  }
66
80
  };
67
81
 
68
- util.inherits(KnexMigrateError, errors.IgnitionError);
69
-
70
- each(knexMigratorErrors, function (error) {
71
- util.inherits(error, KnexMigrateError);
72
- });
73
-
74
- // we need to inherit all general errors from KnexMigrateError, otherwise we have to check instanceof IgnitionError
75
- each(errors, function (error) {
76
- if (error.name === 'IgnitionError' || typeof error === 'object') {
77
- return;
78
- }
79
-
80
- util.inherits(error, KnexMigrateError);
81
- });
82
-
83
82
  module.exports = Object.assign(knexMigratorErrors, errors);
84
83
  module.exports.KnexMigrateError = KnexMigrateError;
package/lib/index.js CHANGED
@@ -233,7 +233,7 @@ KnexMigrator.prototype.init = function init(options) {
233
233
  }).then(function () {
234
234
  throw err;
235
235
  }).catch(function (innerErr) {
236
- if (errors.utils.isIgnitionError(innerErr)) {
236
+ if (errors.utils.isGhostError(innerErr)) {
237
237
  throw err;
238
238
  }
239
239
 
@@ -411,7 +411,7 @@ KnexMigrator.prototype.migrate = async function migrate(options) {
411
411
  logging.info(`Rollback was successful.`);
412
412
  throw err;
413
413
  } catch (innerErr) {
414
- if (errors.utils.isIgnitionError(innerErr)) {
414
+ if (errors.utils.isGhostError(innerErr)) {
415
415
  throw err;
416
416
  }
417
417
 
package/lib/locking.js CHANGED
@@ -36,7 +36,7 @@ module.exports.lock = function (connection) {
36
36
  });
37
37
  })
38
38
  .catch(function (err) {
39
- if (errors.utils.isIgnitionError(err)) {
39
+ if (errors.utils.isGhostError(err)) {
40
40
  throw err;
41
41
  }
42
42
 
@@ -100,7 +100,7 @@ module.exports.unlock = function (connection) {
100
100
  });
101
101
  })
102
102
  .catch(function (err) {
103
- if (errors.utils.isIgnitionError(err)) {
103
+ if (errors.utils.isGhostError(err)) {
104
104
  throw err;
105
105
  }
106
106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knex-migrator",
3
- "version": "4.2.10",
3
+ "version": "5.0.1",
4
4
  "description": "Database migrations with knex.",
5
5
  "keywords": [
6
6
  "ghost",
@@ -28,7 +28,7 @@
28
28
  "license": "MIT",
29
29
  "scripts": {
30
30
  "lint": "eslint --ext .js --cache lib/** test/**",
31
- "test": "LEVEL=fatal _mocha --require test/utils.js --report --exit lcovonly -- test/**/*_spec.js",
31
+ "test": "LEVEL=fatal _mocha --require test/utils.js --report lcovonly --exit -- test/**/*_spec.js",
32
32
  "test:unit": "yarn lint && LEVEL=fatal _mocha --require test/utils.js --report lcovonly -- test/unit/*_spec.js",
33
33
  "posttest": "yarn lint",
34
34
  "coverage": "nyc --reporter=lcov _mocha --require test/utils.js -- test/*_spec.js",
@@ -44,22 +44,22 @@
44
44
  "knex-migrator-rollback": "./bin/knex-migrator-rollback"
45
45
  },
46
46
  "engines": {
47
- "node": "^12.22.1 || ^14.17.0 || ^16.13.0"
47
+ "node": "^14.17.0 || ^16.13.0"
48
48
  },
49
49
  "dependencies": {
50
- "@tryghost/database-info": "0.3.5",
51
- "@tryghost/logging": "2.1.8",
50
+ "@tryghost/database-info": "0.3.7",
51
+ "@tryghost/errors": "1.2.14",
52
+ "@tryghost/logging": "2.2.3",
52
53
  "bluebird": "3.7.2",
53
54
  "commander": "5.1.0",
54
55
  "compare-ver": "2.0.2",
55
56
  "debug": "4.3.4",
56
- "ghost-ignition": "4.6.3",
57
- "knex": "2.0.0",
57
+ "knex": "2.1.0",
58
58
  "lodash": "4.17.21",
59
59
  "moment": "2.24.0",
60
60
  "mysql2": "2.3.3",
61
61
  "nconf": "0.12.0",
62
- "resolve": "1.22.0"
62
+ "resolve": "1.22.1"
63
63
  },
64
64
  "files": [
65
65
  "bin",
@@ -77,6 +77,6 @@
77
77
  "sinon": "9.2.4"
78
78
  },
79
79
  "optionalDependencies": {
80
- "sqlite3": "5.0.8"
80
+ "sqlite3": "5.0.9"
81
81
  }
82
82
  }