Standalone Cascade CLI — `cascade migrate` from any project
The cascade binary lets you run migrations against any project without pulling in @warlock.js/core. Useful when Cascade is the only piece of the warlock stack you’ve adopted, when you want a tight tool for a CI pipeline or container init step, or when you’re scripting migrations outside the dev-server.
If you’re inside a full warlock app you already have warlock migrate — the same code path, with project glue (config-registered migrations, dev-server file discovery) included. This guide is for the standalone case.
What ships
Section titled “What ships”One binary, four commands:
cascade migrate— run all pending migrationscascade migrate:list— print what’s already been executedcascade migrate:rollback— undo the last batch (or everything with--all)cascade migrate:export-sql— write.up.sql/.down.sqlfiles without touching the DB
No db:create, no db:drop-tables, no seed. Those only really make sense inside a project that knows which database to act on — they belong in the warlock CLI. For standalone Cascade, you create and drop the database with whatever tool you’d normally use.
Install and invoke
Section titled “Install and invoke”pnpm add @warlock.js/cascadeCascade ships a cascade bin entry, so npx cascade works once installed — that’s the canonical invocation in CI, container init, and anywhere a production-shape command beats running a local script. If your migrations are .ts files you’ll want to invoke through a TypeScript runtime — Cascade bundles no transpiler:
npx tsx node_modules/.bin/cascade migrateAdd a script in package.json so you don’t type that every time:
{ "scripts": { "migrate": "tsx node_modules/.bin/cascade migrate", "migrate:list": "tsx node_modules/.bin/cascade migrate:list" }}Configure via .env
Section titled “Configure via .env”There’s no cascade.config.{ts,js} to write. Connection and migration settings come from environment variables — .env is auto-loaded from the project root at CLI start:
# Connection — option A: single URLDATABASE_URL=postgres://user:pass@localhost:5432/myapp
# Connection — option B: discrete varsDB_DIALECT=postgres # or mongodbDB_HOST=localhostDB_PORT=5432DB_NAME=myappDB_USER=postgresDB_PASSWORD=secret
# Migration defaults — only set when you need to override Cascade's library defaultsCASCADE_PRIMARY_KEY=uuid # uuid | int | bigInt (default: int)CASCADE_UUID_STRATEGY=v7 # v4 | v7 (default: v4)If you’re coming from a warlock project, the aliases DB_URL, DB_DRIVER, and DB_USERNAME are also accepted — your existing .env works as-is.
The CASCADE_* migration-defaults matter when your migrations declare foreign keys whose type depends on the primary key. Example: a migration that says image_id: uuid().references(Upload.table) only works if uploads.id was created as UUID — and that only happens when migrationDefaults.primaryKey is "uuid". If your project uses UUID primary keys, set CASCADE_PRIMARY_KEY=uuid. For deeper background on migration column types, see the migrations guide.
Where Cascade looks for migration files
Section titled “Where Cascade looks for migration files”Default: ./migrations/**/*.{ts,js,mjs,cjs} from the directory you run the binary in. Drop your migrations under ./migrations and Cascade finds them.
Need a different layout? Pass --path:
npx cascade migrate -p "src/app/**/migrations/*.ts"npx cascade migrate --path "db/schema/*.migration.ts"Quote the glob. On macOS / Linux, bash expands
**and*before passing them to the binary, leaving Cascade with a single resolved filename instead of a glob. Always wrap the pattern in double quotes when it contains shell metacharacters.
Each file must export default a migration class — the same shape you’d write for warlock migrate. Cascade infers the migration name from the filename (02-04-2026_06-31-48-organization.migration.ts → 02-04-2026_06-31-48-organization) and uses the timestamp prefix for ordering when present.
Running migrations
Section titled “Running migrations”npx cascade migrate # run all pendingnpx cascade migrate -f # fresh: rollback all, then run allnpx cascade migrate --sql # export SQL files instead of executingnpx cascade migrate --sql --pending-only # only pending migrationsnpx cascade migrate --sql --compact # strip comments + blank linesmigrate:list reads the _migrations tracking table directly — no files needed:
npx cascade migrate:listTotal Executed Migrations: 5
✔ 11-12-2025_23-58-03-user Executed: 19-05-2026 13:34 Created: 11-12-2025 23:58
✔ 02-04-2026_06-31-48-organization Executed: 19-05-2026 13:34 Created: 04-02-2026 06:31 ...migrate:rollback undoes the last batch by default; pass --all to roll back everything, or --batches N for the last N batches:
npx cascade migrate:rollback # last batchnpx cascade migrate:rollback --all # nuclearnpx cascade migrate:rollback --batches 3 # last three batchesBefore it runs, migrate:rollback (and migrate -f) prints a summary of every collection or table it will drop and every field or column it will unset, with document or row counts where the driver can count them. In development it then proceeds. Elsewhere it asks Continue? (y/N); pass --yes (alias -y) or --force to confirm in a script. With no terminal and neither flag it refuses with an error and a non-zero exit. A rollback that removes no data does not ask. On MongoDB a plain dropColumn() in down() is skipped; see Rolling back on SQL versus MongoDB.
Rollbacks run newest-first — the exact inverse of the order the migrations were applied — so a down() never meets schema that a later migration’s down() has already removed.
migrate:export-sql writes phase-ordered .up.sql and .down.sql files to <cwd>/database/sql/ — useful for code review, reproducing schema changes in another environment, or feeding into a DBA workflow:
npx cascade migrate:export-sqlnpx cascade migrate:export-sql --pending-only --compactOutput and logging
Section titled “Output and logging”Cascade routes progress through @warlock.js/logger’s ConsoleLog channel — the same channel a full warlock app uses, so the per-migration “Migrating: X successfully (12ms)” lines look identical between cascade migrate and warlock migrate. Each line carries an ISO timestamp and [database] [migration] tags.
Programmatic use — the Operations API
Section titled “Programmatic use — the Operations API”cascade is a thin wrapper over the Operations API, which you can call from your own scripts (tests, container init, custom CLIs):
import { runMigrations, rollbackMigrations, freshMigrate, listExecutedMigrations, migrationRunner,} from "@warlock.js/cascade";
// Register your migration classes firstimport CreateUsersTable from "./migrations/create-users.migration";migrationRunner.registerMany([CreateUsersTable /* … */]);
const results = await runMigrations();console.log(`Ran ${results.length} migrations`);See the Operations API reference for every function’s signature.
Two CLIs, same migrations
Section titled “Two CLIs, same migrations”If you’re running both warlock and cascade-standalone against the same database (e.g. warlock for the main app, cascade for a one-off migration script), they share the _migrations tracking table — warlock migrate followed by cascade migrate:list shows the same entries. Make sure CASCADE_PRIMARY_KEY and CASCADE_UUID_STRATEGY match your warlock project’s src/config/database.ts so the two surfaces generate identical SQL.