{"id":47230,"library":"cassandra-shift","title":"cassandra-shift","description":"A Node.js library for forward-only database migrations in Apache Cassandra. Version 0.2.8 is current. Uses ES6 modules; requires Node.js 12+. Provides deterministic, ordered CQL and JavaScript migrations with automatic state tracking in a dedicated table. Designed to embrace Cassandra's no-rollback model. Supports multiple Cassandra clients and includes validation and inspection utilities. Minimal, explicit API.","status":"active","version":"0.2.8","language":"javascript","source_language":"en","source_url":"https://github.com/uwburn/cassandra-shift","tags":["javascript","cassandra","migration","module"],"install":[{"cmd":"npm install cassandra-shift","lang":"bash","label":"npm"},{"cmd":"yarn add cassandra-shift","lang":"bash","label":"yarn"},{"cmd":"pnpm add cassandra-shift","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for interacting with Apache Cassandra; clients must be passed to the constructor.","package":"cassandra-driver","optional":false}],"imports":[{"note":"Package is ESM-only since v0.2. CommonJS require() will fail.","wrong":"const CassandraShift = require('cassandra-shift')","symbol":"CassandraShift","correct":"import CassandraShift from 'cassandra-shift'"},{"note":"The export is a default export, not a named export.","wrong":"import { CassandraShift } from 'cassandra-shift'","symbol":"CassandraShift","correct":"import C from 'cassandra-shift'; const shift = new C(clients, options)"}],"quickstart":{"code":"import { Client } from 'cassandra-driver';\nimport CassandraShift from 'cassandra-shift';\n\nconst clients = [\n  new Client({ contactPoints: ['127.0.0.1'], localDataCenter: 'datacenter1' }),\n  new Client({ contactPoints: ['127.0.0.2'], localDataCenter: 'datacenter2' })\n];\n\nawait Promise.all(clients.map(c => c.connect()));\n\nconst shift = new CassandraShift(clients, {\n  keyspace: 'my_keyspace',\n  dir: './migrations',\n  ensureKeyspace: true,\n  useKeyspace: true\n});\n\nawait shift.migrate();\nconsole.log('Migrations applied.');","lang":"javascript","description":"Initializes two Cassandra clients, creates a migration instance with configuration, and applies pending migrations."},"warnings":[{"fix":"Switch to ES module import syntax (import). Use dynamic import() if needed from CommonJS, but prefer ESM.","message":"Version 0.2 dropped CommonJS support; the package is now ESM-only.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Explicitly create keyspace before migrations if needed.","message":"Options `ensureKeyspace` and `useKeyspace` may be deprecated in future versions; check changelog.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Name files with consistent zero-padded numbers, e.g., '001_init.cql', '002_add_column.js'.","message":"Migration files are executed in lexicographical order; ensure numeric prefixes with leading zeros (e.g., 001, 002).","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use `export default async function(clients) { ... }`.","message":"JavaScript migrations must export a default async function; named exports will be ignored.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Always provide an array with one or more Client instances.","message":"Clients array must contain at least one client; passing an empty array throws an error.","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"search_vec":"'0.2.8':17 '12':25 'apach':14 'api':62 'automat':34 'cassandra':2,15,44,52,64 'cassandra-shift':1 'client':53 'cql':29 'current':19 'databas':11 'dedic':39 'design':41 'determinist':27 'embrac':43 'es6':21 'explicit':61 'forward':9 'forward-on':8 'includ':55 'inspect':58 'javascript':31,63 'librari':6 'migrat':12,32,65 'minim':60 'model':49 'modul':22,66 'multipl':51 'no-rollback':46 'node.js':5,24 'order':28 'provid':26 'requir':23 'rollback':48 'shift':3 'state':35 'support':50 'tabl':40 'track':36 'use':20 'util':59 'valid':56 'version':16","created_at":"2026-06-07T16:50:27.350419+00:00","updated_at":"2026-06-07T16:50:27.350419+00:00","problems":[{"fix":"Change `const CassandraShift = require('cassandra-shift')` to `import CassandraShift from 'cassandra-shift'` and ensure your project is set to use ES modules.","cause":"Using CommonJS require() on an ESM-only package.","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Add `export default async function(clients) { ... }` to the migration file.","cause":"The migration file does not export a default async function.","error":"Error: Migration file './migrations/002_add_age_column.js' doesn't export a function"},{"fix":"Ensure clients is an array, e.g., `[client1, client2]`.","cause":"The clients argument passed to constructor is not an array.","error":"TypeError: clients.map is not a function"}],"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/uwburn/cassandra-shift#readme","github":"https://github.com/uwburn/cassandra-shift","docs":null,"changelog":null,"pypi":null,"npm":"cassandra-shift","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}}