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.)
Arguments
Section titled “Arguments”<script>— Required. Path to the script, relative to the scripts folder.
Where the pin is written
Section titled “Where the pin is written”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.
Interaction with the pinned store
Section titled “Interaction with the pinned store”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.
Examples
Section titled “Examples”Pin a script:
spawn script pin maintenance/reindexRuns then use the pinned tree automatically:
spawn script run maintenance/reindex --yesRe-pin after changing a component the script includes:
spawn script pin maintenance/reindexOptions
| 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. |