compozy migrate

Database migration commands with automatic driver detection for PostgreSQL and SQLite.

Run schema migrations for the active database driver. Compozy detects PostgreSQL or SQLite based on your configuration and applies the correct migration set.

Usage

compozy migrate [command]

Commands

CommandDescription
upApplies all pending migrations.
downRolls back the most recent migration batch.
statusDisplays applied vs. pending migrations.

Multi-Database Support

# Apply migrations (auto-detects driver from compozy.yaml or CLI flags)
compozy migrate up

# Check migration status
compozy migrate status

# Roll back last migration batch
compozy migrate down
  • PostgreSQL and SQLite use separate migration files tuned for each SQL dialect.
  • Switching drivers? Run compozy migrate up after updating database.driver to ensure the new backend schema exists.
  • For SQLite, keep the .db file available before running migrations; the CLI creates it if missing.

Driver Overrides

# Force PostgreSQL migrations even if config defaults apply
compozy migrate up --db-driver=postgres --db-conn-string=postgres://...

# Migrate an SQLite file
compozy migrate up --db-driver=sqlite --db-path=./data/compozy.db

Flags mirror those available on compozy start, ensuring parity between runtime and migration workflows (--db-driver, --db-path, --db-conn-string).

Troubleshooting

  • no such table: migrations were not applied for the selected driver—rerun compozy migrate up.
  • database is locked (SQLite): close other processes and consider enabling WAL mode before retrying.
  • permission denied (PostgreSQL): ensure the database user can create tables, indexes, and sequences.