Skip to content

Commit

Permalink
feat: add supporting query settings, add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
V committed Mar 14, 2023
1 parent 93afe86 commit 56ab433
Show file tree
Hide file tree
Showing 14 changed files with 1,023 additions and 4,292 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib
node_modules
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# clickhouse-migrations

> CLI NodeJS ClickHouse Migrations.
> ClickHouse Migrations CLI
## Install

Expand All @@ -13,9 +13,9 @@ npm install --global clickhouse-migrations

Create a directory, where migrations will be stored. It will be used as the value for the `--migrations-home` option.

In the directory, create migrations - which should be named like: `1_`some_text`.sql`, `2_`other_text`.sql`, ... `10_`more_test`.sql`. What is important here: migration versions followed by underscore - `1_`, `2_`, ...`10_`..., and file extension `.sql`. Any text can follow by version number. The version number should increase for every next migration.
In the directory, create migrations files - which should be named like: `1_`some_text`.sql`, `2_`other_text`.sql`, ... `10_`more_test`.sql`. What is important here: migration versions followed by underscore - `1_`, `2_`, ...`10_`..., and file extension `.sql`. Any text can follow by version number. The version number should increase for every next migration.

For migrations' content should be used correct SQL ClickHouse queries. A few queries can be used in one migration file. Every query should end with `;`. The queries could be idempotent - for example: `CREATE TABLE IF NOT EXISTS table ...;` For adding comments should be used `--`, `# `, `#!` at the beginning of the line.
For migrations' content should be used correct SQL ClickHouse queries. A few queries can be used in one migration file. Every query should end with `;`. The queries could be idempotent - for example: `CREATE TABLE IF NOT EXISTS table ...;` For adding comments should be used `--`, `# `, `#!` at the beginning of the line. Can be used ClickHouse settings - that can be applied on query level, in the format: `SET allow_experimental_object_type = 1;` A migration file can't be changed or removed after applying.

```
Usage
Expand All @@ -37,9 +37,19 @@ For migrations' content should be used correct SQL ClickHouse queries. A few que
CH_MIGRATIONS_DB Database name (--db)
CH_MIGRATIONS_HOME Migrations' directory (--migrations-home)
Examples
CLI examples
clickhouse-migrations migrate --host=http://localhost:8123
--user=default --password='' --db=analytics
--migrations-home=/app/clickhouse/migrations
clickhouse-migrations migrate
Migration file example (could be named 'init-1.sql' and stored in the
directory provided in --migrations-home)
SET allow_experimental_object_type = 1;
CREATE TABLE IF NOT EXISTS events (
event JSON
);
```
Loading

0 comments on commit 56ab433

Please sign in to comment.