Skip to content

#backend

One field note tagged #backend. All notes.

Write the migration so it can run twice

Deploys get retried. Pods restart mid-migration. Someone runs the command again because they weren’t sure it took.

IF NOT EXISTS on creates, IF EXISTS on drops, and a backfill written as an idempotent update rather than an insert. It costs nothing to write it this way the first time and saves an incident later.

The exception is anything destructive. Those I want to fail loudly on a second run, because a DROP COLUMN that quietly succeeds twice means I’ve lost track of what state the database is in.