clickhouse-migrations 0.1.5 → 0.1.6

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/README.md CHANGED
@@ -22,8 +22,8 @@ For migrations' content should be used correct SQL ClickHouse queries. A few que
22
22
  $ clickhouse-migrations migrate <options>
23
23
 
24
24
  Required options
25
- --host=<name> Clickhouse hostname (ex. https://clickhouse)
26
- --port=<number> Port
25
+ --host=<name> Clickhouse hostname
26
+ (ex. https://clickhouse:8123)
27
27
  --user=<name> Username
28
28
  --password=<password> Password
29
29
  --db=<name> Database name
@@ -32,15 +32,14 @@ For migrations' content should be used correct SQL ClickHouse queries. A few que
32
32
  Environment variables
33
33
  Instead of options can be used environment variables.
34
34
  CH_MIGRATIONS_HOST Clickhouse hostname (--host)
35
- CH_MIGRATIONS_PORT Port (--port)
36
35
  CH_MIGRATIONS_USER Username (--user)
37
36
  CH_MIGRATIONS_PASSWORD Password (--password)
38
37
  CH_MIGRATIONS_DB Database name (--db)
39
38
  CH_MIGRATIONS_HOME Migrations' directory (--migrations-home)
40
39
 
41
40
  Examples
42
- clickhouse-migrations migrate --host=http://localhost
43
- --port=8123 --user=default --password=''
44
- --db=analytics --migrations-home=/app/clickhouse/migrations
41
+ clickhouse-migrations migrate --host=http://localhost:8123
42
+ --user=default --password='' --db=analytics
43
+ --migrations-home=/app/clickhouse/migrations
45
44
 
46
45
  clickhouse-migrations migrate
package/lib/migrate.js CHANGED
@@ -61,35 +61,24 @@ var log = function (type, message, error) {
61
61
  console.error('\x1b[36m', "clickhouse-migrations :", '\x1b[31m', "Error: ".concat(message), error ? "\n\n ".concat(error) : '');
62
62
  }
63
63
  };
64
- var connect = function (host, port, username, password, db_name) {
64
+ var connect = function (host, username, password, db_name) {
65
65
  var db_params = {
66
- url: host,
67
- port: parseInt(port),
68
- debug: false,
69
- basicAuth: {
70
- username: username,
71
- password: password,
72
- },
73
- isUseGzip: false,
74
- format: 'json',
75
- raw: false,
76
- config: {
77
- session_timeout: 60,
78
- output_format_json_quote_64bit_integers: 0,
79
- enable_http_compression: 0,
80
- },
66
+ host: host,
67
+ username: username,
68
+ password: password,
69
+ application: 'clickhouse-migrations',
81
70
  };
82
71
  if (db_name) {
83
72
  db_params.database = db_name;
84
73
  }
85
74
  return new createClient(db_params);
86
75
  };
87
- var create_db = function (host, port, username, password, db_name) { return __awaiter(void 0, void 0, void 0, function () {
76
+ var create_db = function (host, username, password, db_name) { return __awaiter(void 0, void 0, void 0, function () {
88
77
  var client, q, e_1;
89
78
  return __generator(this, function (_a) {
90
79
  switch (_a.label) {
91
80
  case 0:
92
- client = connect(host, port, username, password);
81
+ client = connect(host, username, password);
93
82
  q = "CREATE DATABASE IF NOT EXISTS ".concat(db_name, " ENGINE = Atomic");
94
83
  _a.label = 1;
95
84
  case 1:
@@ -279,16 +268,16 @@ var apply_migrations = function (client, migrations, migrations_home) { return _
279
268
  }
280
269
  });
281
270
  }); };
282
- var migration = function (migrations_home, host, port, username, password, db_name) { return __awaiter(void 0, void 0, void 0, function () {
271
+ var migration = function (migrations_home, host, username, password, db_name) { return __awaiter(void 0, void 0, void 0, function () {
283
272
  var migrations, client;
284
273
  return __generator(this, function (_a) {
285
274
  switch (_a.label) {
286
275
  case 0:
287
276
  migrations = get_migrations(migrations_home);
288
- return [4 /*yield*/, create_db(host, port, username, password, db_name)];
277
+ return [4 /*yield*/, create_db(host, username, password, db_name)];
289
278
  case 1:
290
279
  _a.sent();
291
- client = connect(host, port, username, password, db_name);
280
+ client = connect(host, username, password, db_name);
292
281
  return [4 /*yield*/, init_migration_table(client)];
293
282
  case 2:
294
283
  _a.sent();
@@ -304,12 +293,11 @@ var migration = function (migrations_home, host, port, username, password, db_na
304
293
  }); };
305
294
  var migrate = function () {
306
295
  var program = new Command();
307
- program.name('clickhouse-migrations').description('ClickHouse migrations.').version('0.1.5');
296
+ program.name('clickhouse-migrations').description('ClickHouse migrations.').version('0.1.6');
308
297
  program
309
298
  .command('migrate')
310
299
  .description('Apply migrations.')
311
- .requiredOption('--host <name>', 'Clickhouse hostname (ex. https://clickhouse)', process.env.CH_MIGRATIONS_HOST)
312
- .requiredOption('--port <number>', 'Port', process.env.CH_MIGRATIONS_PORT)
300
+ .requiredOption('--host <name>', 'Clickhouse hostname (ex: http://clickhouse:8123)', process.env.CH_MIGRATIONS_HOST)
313
301
  .requiredOption('--user <name>', 'Username', process.env.CH_MIGRATIONS_USER)
314
302
  .requiredOption('--password <password>', 'Password', process.env.CH_MIGRATIONS_PASSWORD)
315
303
  .requiredOption('--db <name>', 'Database name', process.env.CH_MIGRATIONS_DB)
@@ -317,7 +305,7 @@ var migrate = function () {
317
305
  .action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
318
306
  return __generator(this, function (_a) {
319
307
  switch (_a.label) {
320
- case 0: return [4 /*yield*/, migration(options.migrationsHome, options.host, options.port, options.user, options.password, options.db)];
308
+ case 0: return [4 /*yield*/, migration(options.migrationsHome, options.host, options.user, options.password, options.db)];
321
309
  case 1:
322
310
  _a.sent();
323
311
  return [2 /*return*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clickhouse-migrations",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "CLI NodeJS ClickHouse Migrations",
5
5
  "bin": {
6
6
  "clickhouse-migrations": "lib/cli.js"