Skip to content

spawn migration build

Usage

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

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.

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

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 }}.
-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.