The migration failed at 02:13. The logs showed one thing: the schema was out of sync. A new column had been added to production manually, and the staging database had no idea it existed.
Adding a new column sounds simple. In reality, it touches code, database, deploy pipelines, and sometimes compliance. Done wrong, it breaks builds, throws errors, and loses data. Done right, it ships without downtime.
First, define the new column in your migration tool of choice. Explicitly set the data type, default values, and nullability. Avoid implicit changes that vary by environment. Lock migrations to a specific version of your migration framework to prevent drift.
Second, backfill data in a controlled operation. If the column is non-nullable, seed it before applying constraints. Use batched updates to avoid locking large tables. Monitor the process closely with real-time metrics.