Zenlev documentation
Plan TypeScript database migrations around the way your application ships.
Why Zenlev exists
Application releases and database changes rarely fit into one linear sequence. A rolling deployment can leave two application versions writing to the same database. A new column may need to exist before either version uses it. A backfill can run after compatible writers are ready. Removing the old column may wait through a separate release and rollback window.
Zenlev lets you keep those changes in separate TypeScript migrations. Declare which work must happen first, then let your release pipeline decide when to run each eligible group. Independent changes can move between deployment windows without rewriting migrations or their applied history.
- Before deployment
Add compatible schema. Inspect and apply the predeploy namespace.
- During deployment
Deploy compatible application code. Run backfills after its readiness checkpoint.
- After deployment
Verify traffic and data. Retire old schema when the previous application has stopped.
Explicit dependencies leave room to schedule work
Imagine replacing a customer's email column. Adding the new column makes both the backfill and index creation eligible. Either can run first when your application permits it. Retiring the old column waits for both.
A migration's dependsOn entries are requirements. Namespace and tag filters select work, while the ledger shows which requirements a destination has already met. If a pending prerequisite falls outside the selection, Zenlev reports the blocker before invoking migration handlers.
How a migration runs
- Connect. Zenlev uses your configured ZenStack V3 client or Kysely adapter. An environment-aware factory can select the destination.
- Plan. Zenlev reads migration metadata and ledger history, builds the effective graph, and orders eligible work by dependency.
- Inspect. Review selected IDs, warnings, and blockers with
migrate apply --plan-only. Use status and tree to see the current history and dependencies. - Apply. Zenlev acquires the ledger lock, rebuilds the plan, and verifies selected entry-file hashes. Database work and ledger updates share a transaction where supported.
- Respond. Generate a reviewable compensation migration for an unwanted change. Reconcile an interrupted attempt before authorizing a retry.
Namespaces label work within a ledger. Use --env to supply an environment to the client factory. Namespaces and environments shows how both choices fit into staging and production runs.
Find the right page
- Quick start runs your first migration. Staged deployments walks through the complete column replacement.
- Guides cover authoring, selection, schema changes, rollback, recovery, and adopting Zenlev.
- Reference covers CLI syntax, configuration, the typed API, plugins, and telemetry.
- Dialect examples show SQLite, PostgreSQL, and MySQL client setup and transaction behavior.