clickhouse-migrations 1.1.0 → 1.1.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/migrate.js +46 -60
- package/package.json +14 -14
package/lib/migrate.js
CHANGED
|
@@ -35,15 +35,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
40
|
};
|
|
@@ -98,57 +89,52 @@ var connect = function (url, username, password, db_name, timeout, ca_cert, cert
|
|
|
98
89
|
}
|
|
99
90
|
return (0, client_1.createClient)(db_params);
|
|
100
91
|
};
|
|
101
|
-
var create_db = function (
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
case 9:
|
|
146
|
-
_a.sent();
|
|
147
|
-
return [2 /*return*/];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
92
|
+
var create_db = function (host, username, password, db_name, db_engine, timeout, ca_cert, cert, key) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
var client, e_1, q, e_2;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
switch (_a.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
client = connect(host, username, password, undefined, timeout, ca_cert, cert, key);
|
|
98
|
+
_a.label = 1;
|
|
99
|
+
case 1:
|
|
100
|
+
_a.trys.push([1, 3, , 4]);
|
|
101
|
+
return [4 /*yield*/, client.ping()];
|
|
102
|
+
case 2:
|
|
103
|
+
_a.sent();
|
|
104
|
+
return [3 /*break*/, 4];
|
|
105
|
+
case 3:
|
|
106
|
+
e_1 = _a.sent();
|
|
107
|
+
log('error', "Failed to connect to ClickHouse", e_1.message);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
return [3 /*break*/, 4];
|
|
110
|
+
case 4:
|
|
111
|
+
q = db_engine
|
|
112
|
+
? "CREATE DATABASE IF NOT EXISTS \"".concat(db_name, "\" ").concat(db_engine)
|
|
113
|
+
: "CREATE DATABASE IF NOT EXISTS \"".concat(db_name, "\"");
|
|
114
|
+
_a.label = 5;
|
|
115
|
+
case 5:
|
|
116
|
+
_a.trys.push([5, 7, , 8]);
|
|
117
|
+
return [4 /*yield*/, client.exec({
|
|
118
|
+
query: q,
|
|
119
|
+
clickhouse_settings: {
|
|
120
|
+
wait_end_of_query: 1,
|
|
121
|
+
},
|
|
122
|
+
})];
|
|
123
|
+
case 6:
|
|
124
|
+
_a.sent();
|
|
125
|
+
return [3 /*break*/, 8];
|
|
126
|
+
case 7:
|
|
127
|
+
e_2 = _a.sent();
|
|
128
|
+
log('error', "can't create the database ".concat(db_name, "."), e_2.message);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
return [3 /*break*/, 8];
|
|
131
|
+
case 8: return [4 /*yield*/, client.close()];
|
|
132
|
+
case 9:
|
|
133
|
+
_a.sent();
|
|
134
|
+
return [2 /*return*/];
|
|
135
|
+
}
|
|
150
136
|
});
|
|
151
|
-
};
|
|
137
|
+
}); };
|
|
152
138
|
var init_migration_table = function (client) { return __awaiter(void 0, void 0, void 0, function () {
|
|
153
139
|
var q, e_3;
|
|
154
140
|
return __generator(this, function (_a) {
|
|
@@ -353,7 +339,7 @@ var migration = function (migrations_home, host, username, password, db_name, db
|
|
|
353
339
|
exports.migration = migration;
|
|
354
340
|
var migrate = function () {
|
|
355
341
|
var program = new commander_1.Command();
|
|
356
|
-
program.name('clickhouse-migrations').description('ClickHouse migrations.').version('1.1.
|
|
342
|
+
program.name('clickhouse-migrations').description('ClickHouse migrations.').version('1.1.2');
|
|
357
343
|
program
|
|
358
344
|
.command('migrate')
|
|
359
345
|
.description('Apply migrations.')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clickhouse-migrations",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "ClickHouse Migrations",
|
|
5
5
|
"bin": {
|
|
6
6
|
"clickhouse-migrations": "lib/cli.js"
|
|
@@ -28,23 +28,23 @@
|
|
|
28
28
|
"postversion": "git push && git push --tags"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@clickhouse/client": "^1.
|
|
32
|
-
"commander": "^14.0.
|
|
31
|
+
"@clickhouse/client": "^1.16.0",
|
|
32
|
+
"commander": "^14.0.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@eslint/js": "^9.
|
|
35
|
+
"@eslint/js": "^9.39.2",
|
|
36
36
|
"@types/jest": "^30.0.0",
|
|
37
|
-
"@types/node": "^
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
39
|
-
"@typescript-eslint/parser": "^8.
|
|
40
|
-
"eslint": "^9.
|
|
37
|
+
"@types/node": "^20.0.0",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
39
|
+
"@typescript-eslint/parser": "^8.54.0",
|
|
40
|
+
"eslint": "^9.39.2",
|
|
41
41
|
"eslint-config-prettier": "^10.1.8",
|
|
42
|
-
"eslint-plugin-prettier": "^5.5.
|
|
43
|
-
"jest": "^30.0
|
|
44
|
-
"prettier": "^3.
|
|
45
|
-
"ts-jest": "^29.4.
|
|
46
|
-
"typescript": "^5.9.
|
|
47
|
-
"typescript-eslint": "^8.
|
|
42
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
43
|
+
"jest": "^30.2.0",
|
|
44
|
+
"prettier": "^3.8.1",
|
|
45
|
+
"ts-jest": "^29.4.6",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"typescript-eslint": "^8.54.0"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
|
50
50
|
"lib/**/*"
|