Docs
Migrations

Schema migrations

Track and apply ordered SQL schema changes to Silos databases and branches with the silos silo command group.

Schema migrations let you evolve your database structure over time in ordered, reviewable steps. Silos manages migrations through the CLI's silos silo command group: it tracks ordered SQL migration files, applies pending ones to a database or branch, and can roll the most recent ones back.

This page is the conceptual overview. For the full flag-by-flag reference of each subcommand, see silos silo.

How it works

A migration is an ordered SQL file. The CLI keeps a directory of them (by default .silos/migrations), records which have been applied to a given database, and applies the pending ones in order. Because you author plain SQL, anything Postgres supports — CREATE TABLE, ALTER, indexes, constraints, functions — is a valid migration.

The workflow

Initialize migration tracking

Terminal
silos silo init

This sets up the migrations directory for your project.

Generate a migration

Terminal
silos silo generate --name add_users_table

This creates a timestamped, empty migration file. Open it and write your forward SQL (and the reverse SQL if you want rollbacks to work).

Preview, then apply

Run a dry run to see what would execute, then apply for real:

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

This shows which migrations are applied and which are still pending.

Test on a branch first

Because Silos branches are instant, copy-on-write forks, the safest way to validate a migration is to apply it to a branch before touching your primary database.

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

If the migration behaves, apply it to the primary; if not, delete the branch and iterate.

Rollbacks run the reverse SQL you write in each migration — they're only as good as the down-statements you provide. Always test a rollback on a branch before running it against a primary database.

Using your own migration tool

You don't have to use silos silo. Because Silos is real Postgres over the standard wire protocol, framework-native and standalone migration tools — Prisma Migrate, Drizzle Kit, Alembic, Flyway, golang-migrate, Rails migrations — connect with a normal connection string and work as they do against any Postgres. Point them at a branch to test, then at your primary.

Next steps

On this page