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):
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: switching between branches with different migrations can leave the migration table out of sync with the files on disk, and db:migrate fails with a "corrupted migrations" error. Fix it with db:reset.
For full details, see the migration documentation