Schema changes are the riskiest thing most of us ship. This is the list I go through before approving one.
- Does it lock a big table? Adding an index without
CONCURRENTLYblocks writes. - Is it backwards compatible? Old code will run against the new schema for a few minutes during the deploy.
- Can it be undone? Dropping a column is forever. Stop using it first, drop it a week later.
- Has it run on a copy of production data? Timings on an empty database mean nothing.
- 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.
