Documentation
¶
Overview ¶
Command dbmigrate is a small CLI around the dbmigrate package.
Usage:
dbmigrate create <name> create a new {YYYY_MM_DD_HHMMSS}_{name}.up.sql / .down.sql pair
dbmigrate up apply all pending migrations (new batch)
dbmigrate rollback [--step N] roll back the last N batches (default 1)
dbmigrate reset roll back every batch, do not re-apply
dbmigrate refresh roll back everything, then re-apply
dbmigrate fresh drop all tables and re-run every migration from scratch
dbmigrate status list pending migrations
dbmigrate history list applied migrations (name, batch, applied_at)
dbmigrate check verify migration files load (no DB; rejects duplicate names)
dbmigrate baseline record pending migrations as applied without running SQL
(--last-file-to-apply / --lastFileToApply for inclusive cutoff)
Configuration is via CLI flags only — intended to be driven from a Makefile that sets these once and passes them through to every command:
--dsn Database connection string (required except create/check) --driver Driver name: postgres, sqlite (auto-detected from --dsn if omitted) --dir migrations directory (repeatable; default "migrations") --table tracking table name (default "dbmigrate_migrations") --schema schema name, used by fresh (default "public") --step batches to roll back, `rollback` only (default 1) --last-file-to-apply baseline only: last migration base name to mark applied (inclusive) --lastFileToApply alias of --last-file-to-apply --yes skip the confirmation prompt on fresh/refresh/reset/baseline
Click to show internal directories.
Click to hide internal directories.