DOCS / GUIDES

Molt: safe schema migrations

Change your database schema without taking the service offline.

Intermediate13 min read
Before you beginYou need the cluck CLI, a Pollosoft account, and a coop to work in. No prior experience required. Curiosity and a mild fondness for chickens are helpful.

Overview

Change your database schema without taking the service offline. The whole thing takes about 13 minutes, and the commands below are the ones you will use along the way.

$ cluck molt new add-orders-index
$ cluck molt run --dry-run
$ cluck molt run

Steps

  1. Write small migrations. One change per migration. If a migration needs a comment longer than the code, split it.
  2. Dry run. cluck molt run --dry-run shows the SQL it would execute and estimates lock time.
  3. Expand, migrate, contract. Add the new column, backfill it, switch reads, then drop the old column. Never skip a step to save a day.
  4. Roll back. Every migration has a down path. Test it. A rollback you have never run is a rumor.

Commands used

Keep going

Stuck? Check the error codes, the FAQ, or the glossary.