clickhouse-migrations 0.1.7 → 0.1.8

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