Skip to main content
Migrations are plain SQL files in the migrations/ directory, run with sql-migrate. Since they are embedded into your binary, a deployed application carries its own schema history.

Writing Migrations

Migration files are named sequentially with a short description, such as 0001_initial.sql and 0002_create_rockets.sql. Each file has an up and a down section:
migrations/0002_create_rockets.sql

Running Migrations

During development, you rarely need to think about migrations since copper run applies any pending ones before starting your application. If you would like to skip this, pass -migrate=false. You may also run migrations on their own:
To roll back, pass the direction:
down reverts only the most recent migration. You may run it again to step back further.

Migrations in Production

copper build compiles a standalone migrator alongside your app:
Run the migrator as a deploy step before starting (or restarting) the app. To roll back the most recent migration, set the direction with -set:
The value is parsed as TOML, so the inner quotes matter. All of the [csql.migrations] keys are listed in the Configuration Reference.