Skip to main content
Version: v5.7.0

opschain admin database migrations apply

Included from Basic tier

Applies pending migrations server-side — a POST to /api/admin/database/migrations/apply, executed by the server against its own store with the goose provider the boot path uses. Exactly one selector is required:

  • --all applies every pending migration in version order (holes below the maximum applied version included).
  • --id <version> applies exactly one migration, and is refused unless that version is the next pending one — out-of-order application is how the renumber incident corrupted a database, so the server enforces the order the boot path would take.

Any integrity finding other than a hole refuses the apply outright (HTTP 409) with the same error text the boot verification raises: a mismatched ledger means the database and binary disagree about history, and applying more migrations on top entrenches the damage. Applied versions are recorded in the ledger as proven and an api:database:migrations event is written, like the other database maintenance verbs.

The server normally applies pending migrations itself at boot; this verb exists for the emergency lanes — a boot held open with OPSCHAIN_SKIP_MIGRATION_VERIFY=1 while an operator diagnoses, or a controlled step-by-step upgrade rehearsal.

Flags​

FlagMeaning
--server <url>Server base URL (default: the active context / OPSCHAIN_SERVER).
--auth-token <token>Admin bearer token override (default: your opschain login session, then $OPSCHAIN_ADMIN_TOKEN, then the token stored by opschain admin login).
--id <version>Apply exactly this migration version — refused unless it is the next pending migration.
--allApply every pending migration in order.

Exit codes​

CodeMeaning
0The apply ran (possibly applying nothing — the output says so).
1The server refused the apply (mismatch or out-of-order), the request failed, or the token was rejected.
2Usage error — neither or both of --id/--all, no server, or no credential resolvable.

Named errors​

  • pass exactly one of --id <version> or --all — exit 2.
  • refusing to apply version <v> out of order: the next pending migration is <n> — apply that first, or use --all — HTTP 409 (exit 1).
  • refusing to apply migrations: the database's migration history does not match this binary's migrations: … — HTTP 409 (exit 1).

Examples​

opschain admin database migrations apply --all
opschain admin database migrations apply --id 45

See also​

  • opschain docs cli/admin-database-migrations-status — check the verdict before and after.