Menu

1 / 2

5 database migration mistakes that quietly take production down (and how to catch them before deploy)

DEV Community: postgres·AutoAI Muse·1 day ago
#OUyvajUQ
#devtopostgresql#devto#dev#column#migration
Reading 0:00
15s threshold

Every migration on this list passes review. Most of them pass staging, too. They break in production for a boring reason: production is the first place the migration meets real rows, real traffic, and a rolling deploy where old and new code run side by side.

These are the five patterns I check for first when auditing migrations — the same five a deterministic scanner can catch mechanically, before anyone has to learn about them from an incident.

1. The rename that isn't a rename (DROP COLUMN + ADD COLUMN)

You renamed users.name to users.display_name in your Prisma schema. Here is what prisma migrate dev generates:

ALTER TABLE "users" DROP COLUMN "name" ; ALTER TABLE "users" ADD COLUMN "display_name" TEXT ;

Enter fullscreen mode

Exit fullscreen mode

That is not a rename. It is a delete followed by an empty column. Every value in name is gone, and during a rolling deploy the old code — still reading and writing name — starts failing the moment the migration lands.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.