migrate/rollback
db:migrate
Runs any outstanding database migrations:
NODE_ENV=development pnpm psy db:migrate
NODE_ENV=test pnpm psy db:migrate
Options
--skip-sync: Skips syncing local schema after running migrations.-h, --help: Display help for command.
Type sync only runs when NODE_ENV=test — generated types (src/types/db.ts, src/types/dream.ts) are only ever built from the test database. Running db:migrate against development migrates that database but does not update src/types/; run it under the default test environment as well so the types stay current. If sync fails after a migration (for example, a model still references a renamed table), Dream reverts the generated type files to their pre-sync content. The migration itself is unaffected — it already committed and is recorded as applied — so there's no need to db:rollback on the assumption the two are out of sync; fix the underlying problem and run psy sync to regenerate the types.
db:rollback
Rolls back the specified number of migration steps (defaults to 1). Migrations are undone in the reverse of the order this database ran them, not in filename order, so a migration from main that ran after your branch's own — after merging main, say — is undone first:
NODE_ENV=test pnpm psy db:rollback
Roll back multiple migrations at once:
NODE_ENV=test pnpm psy db:rollback --steps 3
Options
--steps <number>: Number of steps back to travel (default: 1).--skip-sync: Skips syncing local schema after running migrations.-h, --help: Display help for command.
db:create
Creates a new database:
NODE_ENV=development pnpm psy db:create
NODE_ENV=test pnpm psy db:create
Options
-h, --help: Display help for command.
db:drop
Drops the database:
NODE_ENV=development pnpm psy db:drop
NODE_ENV=test pnpm psy db:drop
Options
-h, --help: Display help for command.
db:reset
Runs db:drop (safely), db:create, db:migrate, and db:seed.
NODE_ENV=development pnpm psy db:reset
NODE_ENV=test pnpm psy db:reset
Options
-h, --help: Display help for command.
db:seed
Seeds the database using the file located in db/seed.ts.
NODE_ENV=development pnpm psy db:seed
NODE_ENV=test pnpm psy db:seed
Options
-h, --help: Display help for command.
db:integrity-check
Fails if migrations need to be run.
NODE_ENV=test pnpm psy db:integrity-check
Options
-h, --help: Display help for command.
Troubleshooting
"Corrupted migrations" error: the database has recorded a migration whose file is missing — usually after switching between branches with different migrations, or after renaming a migration file that already ran. On the test database, fix it with db:reset. Never rename a migration to reorder it; db:migrate already runs every pending migration, including ones that sort between migrations that have already run.
For full details, see the migration documentation