Skip to content

spawn migration apply

Usage

spawn migration apply [migration] [options]

Applies one or more migrations to the configured database. By default, requires migrations to be pinned for reproducibility.

  • [migration] — Optional. Specific migration to apply. If omitted, applies all pending migrations.
Terminal window
spawn migration apply 20260131120000-add-users-table

Applies the specified migration if not already applied.

Terminal window
spawn migration apply

Shows a list of pending migrations and prompts for confirmation before applying all.

By default, apply requires migrations to have a lock.toml. This ensures the exact same component versions are used every time. Use --no-pin to bypass this requirement and use current working tree components (not recommended for production).

If a migration previously failed, apply will refuse to run it again unless you pass --retry. This prevents accidental re-execution of partially applied migrations. Retrying a successful migration will run the same migration again.

Apply all pending migrations:

Terminal window
spawn migration apply

Apply a specific migration without confirmation:

Terminal window
spawn migration apply 20260131120000-add-users-table --yes

Retry a previously successful or failed migration:

Terminal window
spawn migration apply 20260131120000-add-users-table --retry

Use unpinned components (not recommended):

Terminal window
spawn migration apply 20260131120000-add-users-table --no-pin

Options

Option Description
--no-pin Allow unpinned migrations (use current components)
--variables <path> Path to variables file (JSON, TOML, or YAML). Values are available in templates under {{ variables }}.
--yes Skip confirmation prompt
--retry Retry a previous migration
-e, --environment <name> Override the environment for the target config.
--target <name> Select which target from spawn.toml to use.
--config-file <path> Path to config file. Defaults to spawn.toml.
-d, --debug Turn on debug output.