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.
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.
silos silo init| Flag | Default | Description |
|---|---|---|
--dir <path>, -d | .silos/migrations | Directory for migrations. |
silo generate
Generate a new, empty migration file with a timestamped name. Fill in the SQL, then apply it.
silos silo generate --name add_users_table| Flag | Default | Description |
|---|---|---|
--name <name> | — | Descriptive migration name, for example add_users_table. |
--dir <path>, -d | .silos/migrations | Directory 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:
silos silo apply --database-id db_abc123Apply to a branch:
silos silo apply --database-id db_abc123 --branch previewApply to a direct connection string:
silos silo apply --connection-string "postgres://localhost:5432/postgres"Preview what would run without applying it:
silos silo apply --database-id db_abc123 --dry-run| Flag | Default | Description |
|---|---|---|
--database-id <id> | — | Managed database to apply to. |
--connection-string <url> | — | Direct PostgreSQL connection string to apply to. |
--branch <name>, -b | — | Apply against the named branch. |
--dir <path>, -d | .silos/migrations | Directory for migrations. |
--dry-run | off | Show 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.
silos silo status my-app| Flag | Default | Description |
|---|---|---|
<database> | — | Database ID or name. |
--branch <name>, -b | — | Inspect the named branch. |
--dir <path>, -d | .silos/migrations | Directory for migrations. |
silo rollback
Roll back the most recent migration (or several).
silos silo rollback my-appRoll back the last three migrations:
silos silo rollback my-app --count 3| Flag | Default | Description |
|---|---|---|
<database> | — | Database ID or name. |
--count <n>, -c | 1 | Number of migrations to roll back. |
--branch <name>, -b | — | Roll back on the named branch. |
--dir <path>, -d | .silos/migrations | Directory 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
silos silo initGenerate a migration and write SQL
silos silo generate --name add_users_tableEdit the generated file to add your CREATE TABLE and the reverse statement.
Preview, then apply
silos silo apply --database-id db_abc123 --dry-run
silos silo apply --database-id db_abc123Check status
silos silo status my-app