Skip to content

spawn script new

Usage

spawn script new <script>

Creates a new script folder with a starting script.sql.

  • <script> — Required. Name of the script, as a path relative to the scripts folder. May nest, e.g. maintenance/reindex.

Unlike spawn migration new, the name is used as given — no timestamp prefix. Scripts are neither ordered nor applied once, so there is nothing for a timestamp to sequence.

Creating a script that already exists is an error rather than an overwrite, since the existing one may already have been run.

scripts/maintenance/reindex/
script.sql

The starting script.sql wraps an empty body in BEGIN; / COMMIT;. Delete those two lines for statements that cannot run inside a transaction, such as CREATE INDEX CONCURRENTLY.

To use your own starting content instead of the default template, set template_script in spawn.toml to a path (relative to spawn_folder) of a file to copy into script.sql.

A config.toml appears alongside it once you run spawn script pin, or once you write one yourself to declare variables. Either is optional, and one does not imply the other.

Terminal window
spawn script new reset_demo_data
spawn script new 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.