Skip to content

Commands

Run full migration pipeline: pre-scripts, schema migration, post-scripts.

Terminal window
npx @smplcty/schema-flow run --db postgresql://user:pass@localhost:5432/mydb

Run only pre-scripts (SQL files in schema/pre/).

Run only the schema migration phase (YAML diffing and DDL execution).

Run only post-scripts (SQL files in schema/post/).

Dry-run. Shows planned operations without executing. Equivalent to run --dry-run.

Terminal window
npx @smplcty/schema-flow plan --db postgresql://user:pass@localhost:5432/mydb

Execute the migration plan inside a transaction that is always rolled back. Verifies SQL validity without making changes.

Mark the current database state as baseline. Records all current schema files in the history table without running any migrations. Use when adopting schema-flow on an existing database.

Terminal window
npx @smplcty/schema-flow baseline --db postgresql://user:pass@localhost:5432/mydb

Compare YAML definitions to the live database. Reports differences without making changes.

Terminal window
npx @smplcty/schema-flow drift --db postgresql://user:pass@localhost:5432/mydb

Detect drift and generate + execute a migration plan to fix all differences. Destructive fixes require --allow-destructive.

Static analysis of the migration plan. Warns about dangerous patterns like direct SET NOT NULL, dropping columns, type narrowing, missing FK indexes.

Show migration status: number of applied files, pending changes, and history.

Introspect an existing database and generate YAML files.

Terminal window
npx @smplcty/schema-flow generate --db postgresql://user:pass@localhost:5432/mydb --output-dir ./schema
npx @smplcty/schema-flow generate --db postgresql://... --seeds users,roles # include seed data

Generate a standalone .sql migration file from the current plan.

Terminal window
npx @smplcty/schema-flow sql --output migration.sql --db postgresql://user:pass@localhost:5432/mydb

Output includes transaction grouping, CONCURRENTLY operations outside transactions, phase comments, and blocked operations as comments.

Generate a Mermaid ER diagram from YAML definitions.

Terminal window
npx @smplcty/schema-flow erd --output schema.mmd

Create the standard project directory structure.

Terminal window
npx @smplcty/schema-flow init --dir ./schema

Create timestamped templates.

Terminal window
npx @smplcty/schema-flow new pre --name cleanup
npx @smplcty/schema-flow new post --name refresh-views
npx @smplcty/schema-flow new mixin --name timestamps

Print the YAML format reference to stdout.

Rollback to the previous migration snapshot. See rollback.

Complete the contract phase of an expand/contract migration. Drops old columns and dual-write triggers. Requires --allow-destructive.

Show status of in-progress expand/contract migrations.

Show help text.

Show version number.