knex-migrator 4.1.3 → 4.2.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/LICENSE +1 -1
- package/README.md +2 -2
- package/lib/database.js +13 -5
- package/package.json +5 -5
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ Please add a file named `MigratorConfig.js`. Knex-migrator will load the config
|
|
|
52
52
|
```
|
|
53
53
|
module.exports = {
|
|
54
54
|
database: {
|
|
55
|
-
client: String (Required) ['mysql', 'sqlite3']
|
|
55
|
+
client: String (Required) ['mysql', 'mysql2', 'sqlite3']
|
|
56
56
|
connection: {
|
|
57
57
|
host: String, (Required) [e.g. '127.0.0.1']
|
|
58
58
|
user: String, (Required)
|
|
@@ -338,7 +338,7 @@ knexMigrator.isDatabaseOK()
|
|
|
338
338
|
|
|
339
339
|
# Copyright & License
|
|
340
340
|
|
|
341
|
-
Copyright (c) 2013-
|
|
341
|
+
Copyright (c) 2013-2022 Ghost Foundation - Released under the [MIT license](LICENSE).
|
|
342
342
|
|
|
343
343
|
|
|
344
344
|
|
package/lib/database.js
CHANGED
|
@@ -12,16 +12,24 @@ const knex = require('knex'),
|
|
|
12
12
|
*/
|
|
13
13
|
exports.connect = function connect(options) {
|
|
14
14
|
options = options || {};
|
|
15
|
+
|
|
16
|
+
// Alias `mysql` to `mysql2` so we can maintain backwards compatibility
|
|
17
|
+
if (options.client === 'mysql') {
|
|
18
|
+
options.client = 'mysql2';
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
const client = options.client;
|
|
16
22
|
|
|
17
23
|
if (client === 'sqlite3') {
|
|
18
24
|
options.useNullAsDefault = options.useNullAsDefault || false;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
|
-
if (client === '
|
|
22
|
-
options.connection.timezone = options.connection.timezone || '
|
|
27
|
+
if (client === 'mysql2') {
|
|
28
|
+
options.connection.timezone = options.connection.timezone || 'Z';
|
|
23
29
|
options.connection.charset = options.connection.charset || 'utf8mb4';
|
|
24
|
-
options.connection.
|
|
30
|
+
options.connection.decimalNumbers = true;
|
|
31
|
+
|
|
32
|
+
delete options.connection.filename;
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
return knex(options);
|
|
@@ -102,7 +110,7 @@ exports.createDatabaseIfNotExist = function createDatabaseIfNotExist(dbConfig) {
|
|
|
102
110
|
// @NOTE: Skip, because sqlite3 is a file based database.
|
|
103
111
|
if (dbConfig.client === 'sqlite3') {
|
|
104
112
|
return Promise.resolve();
|
|
105
|
-
} else if (dbConfig.client
|
|
113
|
+
} else if (!['mysql', 'mysql2'].includes(dbConfig.client)) {
|
|
106
114
|
return Promise.reject(new errors.KnexMigrateError({
|
|
107
115
|
message: 'Database is not supported.'
|
|
108
116
|
}));
|
|
@@ -157,7 +165,7 @@ exports.drop = function drop(options) {
|
|
|
157
165
|
const connection = options.connection,
|
|
158
166
|
dbConfig = options.dbConfig;
|
|
159
167
|
|
|
160
|
-
if (dbConfig.client
|
|
168
|
+
if (['mysql', 'mysql2'].includes(dbConfig.client)) {
|
|
161
169
|
debug('Drop database: ' + dbConfig.connection.database);
|
|
162
170
|
|
|
163
171
|
return connection.raw('DROP DATABASE `' + dbConfig.connection.database + '`;')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knex-migrator",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Database migrations with knex.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ghost",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"posttest": "yarn lint",
|
|
34
34
|
"coverage": "nyc --reporter=lcov _mocha --require test/utils.js -- test/*_spec.js",
|
|
35
35
|
"preship": "yarn test",
|
|
36
|
-
"ship": "STATUS=$(git status --porcelain); echo $STATUS; if [ -z \"$STATUS\" ]; then yarn publish && git push ${GHOST_UPSTREAM:-upstream}
|
|
36
|
+
"ship": "STATUS=$(git status --porcelain); echo $STATUS; if [ -z \"$STATUS\" ]; then yarn publish && git push ${GHOST_UPSTREAM:-upstream} main --follow-tags; fi"
|
|
37
37
|
},
|
|
38
38
|
"bin": {
|
|
39
39
|
"knex-migrator": "./bin/knex-migrator",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"bluebird": "3.7.2",
|
|
51
51
|
"commander": "5.1.0",
|
|
52
52
|
"compare-ver": "2.0.2",
|
|
53
|
-
"debug": "4.3.
|
|
53
|
+
"debug": "4.3.3",
|
|
54
54
|
"ghost-ignition": "4.6.3",
|
|
55
55
|
"knex": "0.21.19",
|
|
56
56
|
"lodash": "4.17.21",
|
|
57
57
|
"moment": "2.24.0",
|
|
58
58
|
"nconf": "0.11.3",
|
|
59
|
-
"resolve": "1.
|
|
59
|
+
"resolve": "1.22.0"
|
|
60
60
|
},
|
|
61
61
|
"files": [
|
|
62
62
|
"bin",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"sinon": "9.2.4"
|
|
75
75
|
},
|
|
76
76
|
"optionalDependencies": {
|
|
77
|
-
"
|
|
77
|
+
"mysql2": "2.3.3",
|
|
78
78
|
"sqlite3": "5.0.2"
|
|
79
79
|
}
|
|
80
80
|
}
|