clickhouse-migrations 0.1.6 → 0.1.7
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/migrate.js +6 -10
- package/package.json +1 -1
package/lib/migrate.js
CHANGED
|
@@ -73,12 +73,11 @@ var connect = function (host, username, password, db_name) {
|
|
|
73
73
|
}
|
|
74
74
|
return new createClient(db_params);
|
|
75
75
|
};
|
|
76
|
-
var create_db = function (
|
|
77
|
-
var
|
|
76
|
+
var create_db = function (client, db_name) { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
+
var q, e_1;
|
|
78
78
|
return __generator(this, function (_a) {
|
|
79
79
|
switch (_a.label) {
|
|
80
80
|
case 0:
|
|
81
|
-
client = connect(host, username, password);
|
|
82
81
|
q = "CREATE DATABASE IF NOT EXISTS ".concat(db_name, " ENGINE = Atomic");
|
|
83
82
|
_a.label = 1;
|
|
84
83
|
case 1:
|
|
@@ -94,10 +93,7 @@ var create_db = function (host, username, password, db_name) { return __awaiter(
|
|
|
94
93
|
log('error', "can't create the database ".concat(db_name, "."), e_1.message);
|
|
95
94
|
process.exit(1);
|
|
96
95
|
return [3 /*break*/, 4];
|
|
97
|
-
case 4: return [
|
|
98
|
-
case 5:
|
|
99
|
-
_a.sent();
|
|
100
|
-
return [2 /*return*/];
|
|
96
|
+
case 4: return [2 /*return*/];
|
|
101
97
|
}
|
|
102
98
|
});
|
|
103
99
|
}); };
|
|
@@ -274,10 +270,10 @@ var migration = function (migrations_home, host, username, password, db_name) {
|
|
|
274
270
|
switch (_a.label) {
|
|
275
271
|
case 0:
|
|
276
272
|
migrations = get_migrations(migrations_home);
|
|
277
|
-
|
|
273
|
+
client = connect(host, username, password, db_name);
|
|
274
|
+
return [4 /*yield*/, create_db(client, db_name)];
|
|
278
275
|
case 1:
|
|
279
276
|
_a.sent();
|
|
280
|
-
client = connect(host, username, password, db_name);
|
|
281
277
|
return [4 /*yield*/, init_migration_table(client)];
|
|
282
278
|
case 2:
|
|
283
279
|
_a.sent();
|
|
@@ -293,7 +289,7 @@ var migration = function (migrations_home, host, username, password, db_name) {
|
|
|
293
289
|
}); };
|
|
294
290
|
var migrate = function () {
|
|
295
291
|
var program = new Command();
|
|
296
|
-
program.name('clickhouse-migrations').description('ClickHouse migrations.').version('0.1.
|
|
292
|
+
program.name('clickhouse-migrations').description('ClickHouse migrations.').version('0.1.7');
|
|
297
293
|
program
|
|
298
294
|
.command('migrate')
|
|
299
295
|
.description('Apply migrations.')
|