The schema didn’t match, and the missing piece was a new column.
Adding a new column sounds simple. In production, it’s where mistakes cost hours or bring systems down. The right approach depends on your database, your data size, and your uptime requirements.
In PostgreSQL, ALTER TABLE ADD COLUMN runs fast when the new column has no default. Adding a default to billions of rows, however, can lock the table and freeze writes. The safer pattern is to add the column as NULL, backfill in batches, then set the default and constraints. This avoids long locks and keeps queries live.
MySQL can be trickier on older versions. Schema changes often require table rewrites, which scale poorly. Use tools like pt-online-schema-change or gh-ost to create a shadow table, copy the data, and swap. Newer MySQL versions have instant DDL for certain operations — but verify your exact version and storage engine before trusting it.
In distributed databases, adding a new column might trigger background compactions or node syncs. Monitor performance and replication lag. Always test on staging with realistic data volume.