Skip to content

spawn migration build

Usage

spawn migration build <migration> [--pinned] [--variables <path>] [--reveal-secrets]

Renders a migration’s up.sql template into final SQL, resolving component includes and template variables. Outputs to stdout.

  • <migration> — The migration directory name
  1. Loads the migration’s up.sql template
  2. Resolves component includes from components/ (or pinned/ if --pinned)
  3. Injects template variables from config or --variables file
  4. Renders final SQL to stdout

Without --pinned, the migration uses the current working tree versions of components. With --pinned, it uses the locked versions from the migration’s lock.toml.

Any secret() calls in the template are masked by default (e.g. ***MASKED:name***); pass --reveal-secrets to render real values for local debugging. migration apply always reveals real values, since it actually runs the SQL. See the Secrets guide for full details, including why a masked build still verifies each secret is reachable.

Build with current components:

Terminal window
spawn migration build 20260131120000-add-users-table

Build with pinned components:

Terminal window
spawn migration build 20260131120000-add-users-table --pinned

Build with custom variables:

Terminal window
spawn migration build 20260131120000-add-users-table --variables ./prod-vars.json

Build and show real secret values for debugging:

Terminal window
spawn migration build 20260131120000-add-users-table --reveal-secrets

Options

Option Description
--pinned Use pinned component versions from lock.toml
--variables <path> Path to variables file (JSON, TOML, or YAML). Values are available in templates under {{ variables }}.
--reveal-secrets Render real secret() values instead of masked placeholders. For local debugging only — build output is not executed.
-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.