Docs
CLI

silos silo

Initialize, generate, apply, and roll back schema migrations with the silos silo command group.

The silos silo command group manages schema migrations. It tracks ordered SQL migration files in a directory, applies pending ones to a database or branch, and can roll the most recent ones back.

Terminal
silos silo <subcommand> [options]

By default migrations live in .silos/migrations. Every subcommand accepts a --dir/-d flag to point elsewhere.

silo init

Initialize migration tracking for a project. This sets up the migrations directory.

Terminal
silos silo init
FlagDefaultDescription
--dir <path>, -d.silos/migrationsDirectory for migrations.

silo generate

Generate a new, empty migration file with a timestamped name. Fill in the SQL, then apply it.

Terminal
silos silo generate --name add_users_table
FlagDefaultDescription
--name <name>Descriptive migration name, for example add_users_table.
--dir <path>, -d.silos/migrationsDirectory for migrations.

silo apply

Apply all pending migrations. Target a managed database by ID, or a direct PostgreSQL connection string (handy for silos dev).

Apply to a managed database:

Terminal
silos silo apply --database-id db_abc123

Apply to a branch:

Terminal
silos silo apply --database-id db_abc123 --branch preview

Apply to a direct connection string:

Terminal
silos silo apply --connection-string "postgres://localhost:5432/postgres"

Preview what would run without applying it:

Terminal
silos silo apply --database-id db_abc123 --dry-run
FlagDefaultDescription
--database-id <id>Managed database to apply to.
--connection-string <url>Direct PostgreSQL connection string to apply to.
--branch <name>, -bApply against the named branch.
--dir <path>, -d.silos/migrationsDirectory for migrations.
--dry-runoffShow what would be applied without running it.

Pass either --database-id or --connection-string, not both. Use a connection string to run migrations against a local silos dev server before applying them to a managed database.

silo status

Show which migrations have been applied and which are pending.

Terminal
silos silo status my-app
FlagDefaultDescription
<database>Database ID or name.
--branch <name>, -bInspect the named branch.
--dir <path>, -d.silos/migrationsDirectory for migrations.

silo rollback

Roll back the most recent migration (or several).

Terminal
silos silo rollback my-app

Roll back the last three migrations:

Terminal
silos silo rollback my-app --count 3
FlagDefaultDescription
<database>Database ID or name.
--count <n>, -c1Number of migrations to roll back.
--branch <name>, -bRoll back on the named branch.
--dir <path>, -d.silos/migrationsDirectory for migrations.

Rollbacks run the reverse SQL you provide in each migration. Test rollbacks on a branch before running them against a primary database.

A typical workflow

Initialize

Terminal
silos silo init

Generate a migration and write SQL

Terminal
silos silo generate --name add_users_table

Edit the generated file to add your CREATE TABLE and the reverse statement.

Preview, then apply

Terminal
silos silo apply --database-id db_abc123 --dry-run
silos silo apply --database-id db_abc123

Check status

Terminal
silos silo status my-app

On this page