spawn init
Usage
spawn init [--docker [DATABASE_NAME]] Creates a new Spawn project in the current directory with example configuration and folder structure. Check the Configuration File documentation for more information on how to configure.
Behavior
Section titled “Behavior”Creates:
spawn.toml— Project configuration filemigrations/— Directory for migration scriptscomponents/— Directory for reusable SQL componentstests/— Directory for test scriptsdocker-compose.yaml— (when using--docker) Docker Compose configuration for PostgreSQL
The generated spawn.toml includes a pre-configured database connection that works with the Docker setup (when using --docker).
If spawn.toml already exists, the command will fail to avoid overwriting your configuration.
Examples
Section titled “Examples”Basic initialization
Section titled “Basic initialization”mkdir my-database-projectcd my-database-projectspawn initInitialize with Docker support
Section titled “Initialize with Docker support”mkdir my-database-projectcd my-database-projectspawn init --dockerdocker compose up -dThis creates a docker-compose.yaml configured for a database named “postgres”.
Initialize with custom database name
Section titled “Initialize with custom database name”spawn init --docker myappdocker compose up -dThis creates a docker-compose.yaml configured for a database named “myapp” with container “myapp-db”.
Options
| Option | Description |
|---|---|
--config-file <path> | Path to config file. Defaults to spawn.toml. |
-d, --debug | Turn on debug output. |
--docker [DATABASE_NAME] | Generate a docker-compose.yaml file for local PostgreSQL development. Optionally specify a database/project name (defaults to 'postgres'). |