DEV Community

Bedirhan Elibol
Bedirhan Elibol

Posted on

How do you rename a column without breaking the deploy?

A rename looks like the safest migration there is. It is instant in Postgres. It still broke a deploy for me, because the old version of the app kept running for a few minutes and kept querying the old name.

The only approach I trust is expand and contract: add the new column, write to both, backfill in batches, switch reads, and drop the old column in a later release. It is slow, and it feels like a lot of ceremony for a name change.

Do you do the full sequence, or ship the rename in a maintenance window? And what do you do about ORMs that generate the rename for you?

Top comments (0)