Skip to content

spawn script pin

Usage

spawn script pin <script>

Snapshots the current component tree into the content-addressed store and records its root hash in the script’s config.toml, so that spawn script run resolves includes against exactly what was pinned.

Pinning a script is optional, and pinning it is the decision: an unpinned script resolves against the live component tree, and from the moment it has a pin recorded every run uses the pinned tree instead, without a flag. That is usually the right default for operational SQL — a maintenance script normally wants today’s logic, until you decide a particular script needs to be reproducible, because it was reviewed, because it will be repeated across environments, or because it is run from CI.

To undo a pin, delete the pin line from the script’s config.toml — or the whole file, if it declares nothing else; runs go back to the current components. (spawn pin cleanup will then collect the tree, if nothing else refers to it.)

  • <script> — Required. Path to the script, relative to the scripts folder.

To config.toml inside the script’s own folder. A script named maintenance/reindex gets scripts/maintenance/reindex/config.toml, alongside its script.sql.

The file is rewritten in place rather than replaced, so any declared variables in it survive being pinned and re-pinned. It may also exist without a pin at all, holding only variables — in which case the script is not pinned, and spawn pin verify and spawn pin cleanup account for no tree on its behalf.

A script’s recorded pin counts as a reference to its root hash, just as a migration’s lock.toml does. spawn pin cleanup will not collect a tree that only a pinned script refers to, and spawn pin verify checks those roots too.

Note that spawn check does not report unpinned scripts. Pinning is expected for migrations and optional for scripts.

Pin a script:

Terminal window
spawn script pin maintenance/reindex

Runs then use the pinned tree automatically:

Terminal window
spawn script run maintenance/reindex --yes

Re-pin after changing a component the script includes:

Terminal window
spawn script pin maintenance/reindex

Options

Option Description
-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.