{"id":47227,"library":"cassandra-migrate","title":"cassandra-migrate","description":"A Node.js CLI tool for incremental Cassandra schema migrations using the DataStax Cassandra driver. Current stable version is 1.2.333. It supports up/down migrations, automatic migration ordering by timestamp, and rollback to a specific migration number. Key differentiators: uses timestamped migration files, supports configuration via CLI flags, environment variables, or a JavaScript configuration file. The tool tracks applied migrations in a Cassandra table and can skip migrations. Note that version 1.1.2 introduced a migration table format change requiring an update migration.","status":"active","version":"1.2.333","language":"javascript","source_language":"en","source_url":"https://github.com/rleenders/cassandra-migrate","tags":["javascript","cassandra","migrations","cql","migration","node"],"install":[{"cmd":"npm install cassandra-migrate","lang":"bash","label":"npm"},{"cmd":"yarn add cassandra-migrate","lang":"bash","label":"yarn"},{"cmd":"pnpm add cassandra-migrate","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to connect to and execute queries against Cassandra.","package":"cassandra-driver","optional":false}],"imports":[{"note":"This is a CLI tool, not a library. Use npm globally or via npx.","wrong":"import cassandraMigrate from 'cassandra-migrate';","symbol":"cassandra-migrate (CLI)","correct":"npm install -g cassandra-migrate"}],"quickstart":{"code":"npm install -g cassandra-migrate\ncassandra-migrate create initial_schema\n# Edit ./migrations/<timestamp>_initial_schema.js\ncassandra-migrate up -k my_keyspace -H localhost -u cassandra -p cassandra\ncassandra-migrate down -k my_keyspace","lang":"javascript","description":"Install the CLI, create a new migration, run it, and roll it back using command-line flags for keyspace and credentials."},"warnings":[{"fix":"Copy the provided 0000000000_updateMigrationTable.js migration into your migrations folder and run it before any other migrations.","message":"Migration table format changed in version 1.1.2. Existing tables will cause errors if not updated.","severity":"breaking","affected_versions":">=1.0.0 <1.1.2"},{"fix":"Use -o <path/to/config.js> or set DBHOST, DBUSER, DBPASSWORD environment variables.","message":"CLI flags -H, -u, -p are deprecated in favor of configuration file (-o) or environment variables.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Use the `create` command to generate files with correct timestamps.","message":"Migration file names must be timestamped with at least 10 digits (e.g., 1546300800_create_table.js). Non-conforming names will be ignored or cause errors.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure your config file uses module.exports = { ... } and is a .js file.","message":"Cassandra client configuration file must be a CommonJS module exporting an options object. If using ES modules, the tool will fail.","severity":"gotcha","affected_versions":">=1.2.0"},{"fix":"Only skip migrations when you are certain the schema is already applied or unapplied manually.","message":"The -s (skip) flag adds or removes the migration from the table without executing any scripts. This can leave the database in an inconsistent state if used incorrectly.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.1.2':73 '1.2.333':22 'appli':60 'automat':27 'cassandra':2,10,16,64,85 'cassandra-migr':1 'chang':79 'cli':6,48 'configur':46,55 'cql':87 'current':18 'datastax':15 'differenti':40 'driver':17 'environ':50 'file':44,56 'flag':49 'format':78 'increment':9 'introduc':74 'javascript':54,84 'key':39 'migrat':3,12,26,28,37,43,61,69,76,83,86,88 'node':89 'node.js':5 'note':70 'number':38 'order':29 'requir':80 'rollback':33 'schema':11 'skip':68 'specif':36 'stabl':19 'support':24,45 'tabl':65,77 'timestamp':31,42 'tool':7,58 'track':59 'up/down':25 'updat':82 'use':13,41 'variabl':51 'version':20,72 'via':47","created_at":"2026-06-07T16:50:26.736850+00:00","updated_at":"2026-06-07T16:50:26.736850+00:00","problems":[{"fix":"Create the keyspace first with: CREATE KEYSPACE my_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};","cause":"The specified keyspace does not exist in the Cassandra cluster.","error":"Error: NoSuchKeyspaceError: Keyspace 'my_keyspace' does not exist"},{"fix":"Run `cassandra-migrate up -k <keyspace>` with an empty migrations folder to create the table.","cause":"The tool tries to read the migration table but it hasn't been created yet.","error":"Error: Migration table 'schema_migrations' not found. Run 'cassandra-migrate up -k <keyspace>' first."},{"fix":"Start Cassandra service or provide correct host/port via -H flag or environment variables.","cause":"Cassandra is not running or not reachable at localhost:9042.","error":"Error: All hosts failed to connect: HostAttemptResult: [Error: All host(s) tried for query failed. First host tried, 127.0.0.1:9042: Error: connect ECONNREFUSED 127.0.0.1:9042]"},{"fix":"Rename the migration file to use a proper timestamp, e.g., 1546300800_my_migration.js. Better yet, use the `create` command.","cause":"The migration file name does not start with a valid Unix timestamp (10 digits).","error":"Error: Migration number must be a 10-digit timestamp"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/rleenders/cassandra-migrate#readme","github":"https://github.com/rleenders/cassandra-migrate","docs":null,"changelog":null,"pypi":null,"npm":"cassandra-migrate","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}