db migrate
Apply pending Prisma 8 migrations.
db migrate applies pending on-disk migrations to advance the database. It walks every contract space (app and extensions) and applies migrations in canonical order: extensions alphabetically, then the app. It applies only the migrations that exist on disk and never generates new operations.
Use it from a controlled deployment step after reviewing migration packages.
Usage
bunx prisma@latest db migrate --db "$DATABASE_URL"Options
| Option | What it does |
|---|---|
--db <url> | Connects to the database. |
--to <contract> | Applies migrations up to a target contract (hash, prefix, ref name, migration directory name, <dir>^, or ./path). |
--advance-ref <name> | Advances the named ref to the post-apply marker after success. |
--show | Previews the migration route without applying (read-only). |
--from <contract> | Sets the from-state for the --show preview: @contract (the emitted contract), @db (the database's current marker), a hash, a ref name, or a migration directory. |
--config <path> | Read this config file instead of ./prisma.config.ts. |
--json | Prints a machine-readable result. |
Recommended flow
bunx prisma@latest migration status --db "$DATABASE_URL"
bunx prisma@latest db migrate --db "$DATABASE_URL"
bunx prisma@latest migration status --db "$DATABASE_URL"
bunx prisma@latest db verify --db "$DATABASE_URL"Run migration status before and after applying migrations to see what changed.
Previewing the route
--show prints the route db migrate would take without touching the database:
bunx prisma@latest db migrate --show
bunx prisma@latest db migrate --show --from @contract --to productionApplying to a target
If your project uses named refs, apply up to a target ref:
bunx prisma@latest db migrate --db "$DATABASE_URL" --to productionManage refs with migration ref.
