knex-migrator 4.1.3 → 4.2.0
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 +10 -5
- package/package.json +4 -4
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,21 @@ 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.collation = options.connection.collation || 'utf8mb4_general_ci';
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
return knex(options);
|
|
@@ -102,7 +107,7 @@ exports.createDatabaseIfNotExist = function createDatabaseIfNotExist(dbConfig) {
|
|
|
102
107
|
// @NOTE: Skip, because sqlite3 is a file based database.
|
|
103
108
|
if (dbConfig.client === 'sqlite3') {
|
|
104
109
|
return Promise.resolve();
|
|
105
|
-
} else if (dbConfig.client
|
|
110
|
+
} else if (!['mysql', 'mysql2'].includes(dbConfig.client)) {
|
|
106
111
|
return Promise.reject(new errors.KnexMigrateError({
|
|
107
112
|
message: 'Database is not supported.'
|
|
108
113
|
}));
|
|
@@ -157,7 +162,7 @@ exports.drop = function drop(options) {
|
|
|
157
162
|
const connection = options.connection,
|
|
158
163
|
dbConfig = options.dbConfig;
|
|
159
164
|
|
|
160
|
-
if (dbConfig.client
|
|
165
|
+
if (['mysql', 'mysql2'].includes(dbConfig.client)) {
|
|
161
166
|
debug('Drop database: ' + dbConfig.connection.database);
|
|
162
167
|
|
|
163
168
|
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.0",
|
|
4
4
|
"description": "Database migrations with knex.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ghost",
|
|
@@ -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
|
}
|