Gathering detailed insights and metrics for @shini4i/clickhouse-migrations
Gathering detailed insights and metrics for @shini4i/clickhouse-migrations
Gathering detailed insights and metrics for @shini4i/clickhouse-migrations
Gathering detailed insights and metrics for @shini4i/clickhouse-migrations
CLI tool for automatically adjusting CI_JOB_TOKEN access scope based on project dependencies in GitLab.
npm install @shini4i/clickhouse-migrations
Typescript
Module System
Node Version
NPM Version
69.6
Supply Chain
91.2
Quality
76.9
Maintenance
100
Vulnerability
100
License
TypeScript (95.4%)
JavaScript (3.17%)
Makefile (1.43%)
Total Downloads
199
Last Day
4
Last Week
5
Last Month
12
Last Year
199
MIT License
1 Stars
28 Commits
1 Watchers
1 Branches
2 Contributors
Updated on Mar 25, 2025
Minified
Minified + Gzipped
Latest Version
0.1.16
Package Id
@shini4i/clickhouse-migrations@0.1.16
Unpacked Size
23.12 kB
Size
6.82 kB
File Count
9
NPM Version
10.8.1
Node Version
22.3.0
Published on
Jun 28, 2024
Cumulative downloads
Total Downloads
Last Day
300%
4
Compared to previous day
Last Week
400%
5
Compared to previous week
Last Month
100%
12
Compared to previous month
Last Year
0%
199
Compared to previous year
2
5
1npm install -g @shini4i/clickhouse-migrations
Create a directory, where migrations will be stored. It will be used as the value for the --migrations-home
option (or for environment variable CH_MIGRATIONS_HOME
).
In the directory, create migration files, which should be named like this: 01_some_text.sql
, 02_other_text.sql
, 10_more_test.sql
. What's important here is that the migration version number should come first, followed by an underscore (_
), and then any text can follow. The version number should increase for every next migration. Please note that once a migration file has been applied to the database, it cannot be modified or removed.
For migrations' content should be used correct SQL ClickHouse queries. Multiple queries can be used in a single migration file, and each query should be terminated with a semicolon (;). The queries could be idempotent - for example: CREATE TABLE IF NOT EXISTS table ...;
Clickhouse settings, that can be included at the query level, can be added like SET allow_experimental_object_type = 1;
. For adding comments should be used --
, #
, #!
.
If the database provided in the --db
option (or in CH_MIGRATIONS_DB
) doesn't exist, it will be created automatically.
Usage
$ clickhouse-migrations migrate <options>
Required flags
--url=<url> Clickhouse URL (ex. https://clickhouse:8123)
--user=<name> Username
--db=<name> Database name
--migrations-home=<dir> Migrations' directory
Optional flags
--password=<password> Password
--engine=<engine> The engine to use for DB creation
--request-timeout=<milliseconds> Request timeout in milliseconds
Environment variables
Instead of options can be used environment variables.
CH_MIGRATIONS_URL Clickhouse hostname (--url)
CH_MIGRATIONS_USER Username (--user)
CH_MIGRATIONS_PASSWORD Password (--password)
CH_MIGRATIONS_DB Database name (--db)
CH_MIGRATIONS_HOME Migrations' directory (--migrations-home)
CH_MIGRATIONS_ENGINE The engine to use for DB creation (optional)
CH_MIGRATIONS_REQUEST_TIMEOUT Clickhouse client request timeout (optional)
CLI examples
clickhouse-migrations migrate --url=http://localhost:8123
--user=default --db=analytics
--migrations-home=/app/clickhouse/migrations
clickhouse-migrations migrate
Migration file example:
-- an example of migration file 01_init.sql
SET allow_experimental_object_type = 1;
CREATE TABLE IF NOT EXISTS events (
event JSON
);
No vulnerabilities found.
No security vulnerabilities found.