What I check before merging a migration

A short checklist that has saved me from at least two outages.

Colourful code on a dark monitor

Schema changes are the riskiest thing most of us ship. This is the list I go through before approving one.

  1. Does it lock a big table? Adding an index without CONCURRENTLY blocks writes.
  2. Is it backwards compatible? Old code will run against the new schema for a few minutes during the deploy.
  3. Can it be undone? Dropping a column is forever. Stop using it first, drop it a week later.
  4. Has it run on a copy of production data? Timings on an empty database mean nothing.
  5. Is the default value safe? A new non-null column needs one, and filling it can be slow.

None of this is clever. It is just easy to forget at five on a Friday.

Spotted a mistake?

Tell me and I will fix the post

Corrections are credited at the bottom of the article.