Registry / database / cassandra-migrate

cassandra-migrate

JSON →
library1.2.333jsnpmunverified

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.

npm install cassandra-migrate
INSTALL
IMPORT
SIG · CASSANDRA-MIGRATE
C
cassandra-migrate
databasejavascriptv1.2.333
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cassandra-migrate (CLI)
✓ npm install -g cassandra-migrate
✗ import cassandraMigrate from 'cassandra-migrate';
This is a CLI tool, not a library. Use npm globally or via npx.

Install the CLI, create a new migration, run it, and roll it back using command-line flags for keyspace and credentials.

npm install -g cassandra-migrate cassandra-migrate create initial_schema # Edit ./migrations/<timestamp>_initial_schema.js cassandra-migrate up -k my_keyspace -H localhost -u cassandra -p cassandra cassandra-migrate down -k my_keyspace
Debug
Known issues
breakingMigration table format changed in version 1.1.2. Existing tables will cause errors if not updated.
fix
Copy the provided 0000000000_updateMigrationTable.js migration into your migrations folder and run it before any other migrations.
affects: >=1.0.0 <1.1.2
deprecatedCLI flags -H, -u, -p are deprecated in favor of configuration file (-o) or environment variables.
fix
Use -o <path/to/config.js> or set DBHOST, DBUSER, DBPASSWORD environment variables.
affects: >=1.2.0
gotchaMigration 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.
fix
Use the `create` command to generate files with correct timestamps.
affects: *
gotchaCassandra client configuration file must be a CommonJS module exporting an options object. If using ES modules, the tool will fail.
fix
Ensure your config file uses module.exports = { ... } and is a .js file.
affects: >=1.2.0
gotchaThe -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.
fix
Only skip migrations when you are certain the schema is already applied or unapplied manually.
affects: *
Errors
Common errors & fixes
Error: NoSuchKeyspaceError: Keyspace 'my_keyspace' does not exist
The specified keyspace does not exist in the Cassandra cluster.
fix
Create the keyspace first with: CREATE KEYSPACE my_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
Error: Migration table 'schema_migrations' not found. Run 'cassandra-migrate up -k <keyspace>' first.
The tool tries to read the migration table but it hasn't been created yet.
fix
Run `cassandra-migrate up -k <keyspace>` with an empty migrations folder to create the table.
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]
Cassandra is not running or not reachable at localhost:9042.
fix
Start Cassandra service or provide correct host/port via -H flag or environment variables.
Error: Migration number must be a 10-digit timestamp
The migration file name does not start with a valid Unix timestamp (10 digits).
fix
Rename the migration file to use a proper timestamp, e.g., 1546300800_my_migration.js. Better yet, use the `create` command.
Upgrade
Version history
1.2.333latest on npm
Audit
Dependencies
cassandra-driverrequiredRequired to connect to and execute queries against Cassandra.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
cassandra-migrate — npm install cassandra-migrate · libregistry