knex-migrator 4.2.11 → 5.0.2
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 +67 -68
- package/lib/index.js +2 -2
- package/lib/locking.js +2 -2
- package/package.json +9 -9
package/lib/errors.js
CHANGED
|
@@ -1,84 +1,83 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const errors = require('ghost-ignition').errors;
|
|
1
|
+
const errors = require('@tryghost/errors');
|
|
2
|
+
const merge = require('lodash/merge');
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
options = options || {};
|
|
7
|
-
errors.IgnitionError.call(this, options);
|
|
8
|
-
}
|
|
4
|
+
class KnexMigrateError extends errors.MigrationError {}
|
|
9
5
|
|
|
10
6
|
const knexMigratorErrors = {
|
|
11
|
-
MigrationExistsError:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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": "
|
|
3
|
+
"version": "5.0.2",
|
|
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
|
|
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": "^
|
|
47
|
+
"node": "^14.17.0 || ^16.13.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@tryghost/database-info": "0.3.
|
|
51
|
-
"@tryghost/
|
|
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
|
-
"
|
|
57
|
-
"knex": "2.1.0",
|
|
57
|
+
"knex": "2.2.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.
|
|
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.
|
|
80
|
+
"sqlite3": "5.0.10"
|
|
81
81
|
}
|
|
82
82
|
}
|