Commands
Migration
Section titled “Migration”schema-flow run
Section titled “schema-flow run”Run full migration pipeline: pre-scripts, schema migration, post-scripts.
npx @smplcty/schema-flow run --db postgresql://user:pass@localhost:5432/mydbschema-flow run pre
Section titled “schema-flow run pre”Run only pre-scripts (SQL files in schema/pre/).
schema-flow run migrate
Section titled “schema-flow run migrate”Run only the schema migration phase (YAML diffing and DDL execution).
schema-flow run post
Section titled “schema-flow run post”Run only post-scripts (SQL files in schema/post/).
schema-flow plan
Section titled “schema-flow plan”Dry-run. Shows planned operations without executing. Equivalent to run --dry-run.
npx @smplcty/schema-flow plan --db postgresql://user:pass@localhost:5432/mydbschema-flow validate
Section titled “schema-flow validate”Execute the migration plan inside a transaction that is always rolled back. Verifies SQL validity without making changes.
schema-flow baseline
Section titled “schema-flow baseline”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.
npx @smplcty/schema-flow baseline --db postgresql://user:pass@localhost:5432/mydbAnalysis
Section titled “Analysis”schema-flow drift
Section titled “schema-flow drift”Compare YAML definitions to the live database. Reports differences without making changes.
npx @smplcty/schema-flow drift --db postgresql://user:pass@localhost:5432/mydbschema-flow drift --apply
Section titled “schema-flow drift --apply”Detect drift and generate + execute a migration plan to fix all differences. Destructive fixes require --allow-destructive.
schema-flow lint
Section titled “schema-flow lint”Static analysis of the migration plan. Warns about dangerous patterns like direct SET NOT NULL, dropping columns, type narrowing, missing FK indexes.
schema-flow status
Section titled “schema-flow status”Show migration status: number of applied files, pending changes, and history.
Generation
Section titled “Generation”schema-flow generate
Section titled “schema-flow generate”Introspect an existing database and generate YAML files.
npx @smplcty/schema-flow generate --db postgresql://user:pass@localhost:5432/mydb --output-dir ./schemanpx @smplcty/schema-flow generate --db postgresql://... --seeds users,roles # include seed dataschema-flow sql
Section titled “schema-flow sql”Generate a standalone .sql migration file from the current plan.
npx @smplcty/schema-flow sql --output migration.sql --db postgresql://user:pass@localhost:5432/mydbOutput includes transaction grouping, CONCURRENTLY operations outside transactions, phase comments, and blocked operations as comments.
schema-flow erd
Section titled “schema-flow erd”Generate a Mermaid ER diagram from YAML definitions.
npx @smplcty/schema-flow erd --output schema.mmdschema-flow init
Section titled “schema-flow init”Create the standard project directory structure.
npx @smplcty/schema-flow init --dir ./schemaschema-flow new pre|post|mixin
Section titled “schema-flow new pre|post|mixin”Create timestamped templates.
npx @smplcty/schema-flow new pre --name cleanupnpx @smplcty/schema-flow new post --name refresh-viewsnpx @smplcty/schema-flow new mixin --name timestampsschema-flow docs
Section titled “schema-flow docs”Print the YAML format reference to stdout.
Rollback & expand/contract
Section titled “Rollback & expand/contract”schema-flow down
Section titled “schema-flow down”Rollback to the previous migration snapshot. See rollback.
schema-flow contract
Section titled “schema-flow contract”Complete the contract phase of an expand/contract migration. Drops old columns and dual-write triggers. Requires --allow-destructive.
schema-flow expand-status
Section titled “schema-flow expand-status”Show status of in-progress expand/contract migrations.
Utility
Section titled “Utility”schema-flow help
Section titled “schema-flow help”Show help text.
schema-flow --version
Section titled “schema-flow --version”Show version number.