Skip to content

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.

Creates:

  • spawn.toml — Project configuration file
  • migrations/ — Directory for migration scripts
  • components/ — Directory for reusable SQL components
  • tests/ — Directory for test scripts
  • docker-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.

Terminal window
mkdir my-database-project
cd my-database-project
spawn init
Terminal window
mkdir my-database-project
cd my-database-project
spawn init --docker
docker compose up -d

This creates a docker-compose.yaml configured for a database named “postgres”.

Terminal window
spawn init --docker myapp
docker compose up -d

This 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').