{"id":37148034,"url":"https://github.com/vvvi/clickhouse-migrations","last_synced_at":"2026-01-14T17:28:32.338Z","repository":{"id":63641927,"uuid":"566064844","full_name":"VVVi/clickhouse-migrations","owner":"VVVi","description":"ClickHouse Migrations NodeJS CLI","archived":false,"fork":false,"pushed_at":"2025-09-30T18:21:44.000Z","size":528,"stargazers_count":58,"open_issues_count":5,"forks_count":20,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-22T11:39:35.853Z","etag":null,"topics":["clickhouse","clickhouse-migrations","migration","migrations","nodejs","npm"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/clickhouse-migrations","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VVVi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-11-14T22:29:01.000Z","updated_at":"2025-10-01T05:13:50.000Z","dependencies_parsed_at":"2024-02-02T22:23:46.561Z","dependency_job_id":"202e6c07-0e47-4b16-868a-7016e7450bdd","html_url":"https://github.com/VVVi/clickhouse-migrations","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.0714285714285714,"last_synced_commit":"56ab4337830aa2922e72292dfbe22ecbdbe73292"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/VVVi/clickhouse-migrations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VVVi%2Fclickhouse-migrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VVVi%2Fclickhouse-migrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VVVi%2Fclickhouse-migrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VVVi%2Fclickhouse-migrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VVVi","download_url":"https://codeload.github.com/VVVi/clickhouse-migrations/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VVVi%2Fclickhouse-migrations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28427875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clickhouse","clickhouse-migrations","migration","migrations","nodejs","npm"],"created_at":"2026-01-14T17:28:31.774Z","updated_at":"2026-01-14T17:28:32.333Z","avatar_url":"https://github.com/VVVi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# clickhouse-migrations\n\n\u003e ClickHouse Migrations CLI\n\n## Install\n\n```sh\nnpm install clickhouse-migrations\n```\n\n## Usage\n\nCreate 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`).\n\nIn the directory, create migration files, which should be named like this: `1_some_text.sql`, `2_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. \n\nFor 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 `--`, `# `, `#!`. \n\nIf the database provided in the `--db` option (or in `CH_MIGRATIONS_DB`) doesn't exist, it will be created automatically.\n\nFor TLS/HTTPS connections, you can provide a custom CA certificate and optional client certificate/key via the `--ca-cert`, `--cert`, and `--key` options (or the `CH_MIGRATIONS_CA_CERT`, `CH_MIGRATIONS_CERT`, and `CH_MIGRATIONS_KEY` environment variables).\n\n```\n  Usage\n    $ clickhouse-migrations migrate \u003coptions\u003e\n\n  Required options\n      --host=\u003cname\u003e             Clickhouse hostname \n                                  (ex. https://clickhouse:8123)\n      --user=\u003cname\u003e             Username\n      --password=\u003cpassword\u003e     Password\n      --db=\u003cname\u003e               Database name\n      --migrations-home=\u003cdir\u003e   Migrations' directory\n\n  Optional options\n      --db-engine=\u003cvalue\u003e       ON CLUSTER and/or ENGINE for DB\n                                  (default: 'ENGINE=Atomic')\n      --timeout=\u003cvalue\u003e         Client request timeout \n                                  (milliseconds, default: 30000)\n      --ca-cert=\u003cpath\u003e          CA certificate file path\n      --cert=\u003cpath\u003e             Client certificate file path\n      --key=\u003cpath\u003e              Client key file path                            \n\n  Environment variables\n      Instead of options can be used environment variables.\n      CH_MIGRATIONS_HOST        Clickhouse hostname (--host)\n      CH_MIGRATIONS_USER        Username (--user)\n      CH_MIGRATIONS_PASSWORD    Password (--password)\n      CH_MIGRATIONS_DB          Database name (--db)\n      CH_MIGRATIONS_HOME        Migrations' directory (--migrations-home)\n\n      CH_MIGRATIONS_DB_ENGINE   (optional) DB engine (--db-engine)\n      CH_MIGRATIONS_TIMEOUT     (optional) Client request timeout \n                                  (--timeout)\n      CH_MIGRATIONS_CA_CERT     (optional) CA certificate file path\n      CH_MIGRATIONS_CERT        (optional) Client certificate file path\n      CH_MIGRATIONS_KEY         (optional) Client key file path\n\n\n  CLI executions examples\n    settings are passed as command-line options\n      clickhouse-migrations migrate --host=http://localhost:8123\n      --user=default --password='' --db=analytics \n      --migrations-home=/app/clickhouse/migrations\n\n    settings provided as options, including timeout and db-engine\n      clickhouse-migrations migrate --host=http://localhost:8123 \n      --user=default --password='' --db=analytics \n      --migrations-home=/app/clickhouse/migrations --timeout=60000 \n      --db-engine=\"ON CLUSTER default ENGINE=Replicated('{replica}')\"    \n\n    settings provided as environment variables\n      clickhouse-migrations migrate\n\n    settings provided partially through options and environment variables\n      clickhouse-migrations migrate --timeout=60000\n\n    settings provided as options with TLS certificates\n      clickhouse-migrations migrate --host=https://localhost:8443\n      --user=default --password='' --db=analytics\n      --migrations-home=/app/clickhouse/migrations\n      --ca-cert=/app/certs/ca.pem --cert=/app/certs/client.crt --key=/app/certs/client.key\n```\n\nMigration file example:\n(e.g., located at /app/clickhouse/migrations/1_init.sql)\n```\n-- an example of migration file 1_init.sql\n\nSET allow_experimental_json_type = 1;\n\nCREATE TABLE IF NOT EXISTS events (\n  timestamp DateTime('UTC'),\n  session_id UInt64,\n  event JSON\n)\nENGINE=AggregatingMergeTree\nPARTITION BY toYYYYMM(timestamp) \nSAMPLE BY session_id \nORDER BY (session_id) \nSETTINGS index_granularity = 8192;\n```      ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvvi%2Fclickhouse-migrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvvvi%2Fclickhouse-migrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvvi%2Fclickhouse-migrations/lists"}