The query was fast, but the data schema wasn’t ready. You needed a new column in production, and you needed it now. Delay wasn’t an option.
Adding a new column sounds simple until you factor in uptime, backwards compatibility, and deployment safety. In a live database with active traffic, schema changes can lock tables, spike latency, or even take services down. The key is to plan the migration to avoid risk while keeping development velocity high.
Start by defining the new column in your local schema and committing it to version control. Use explicit types. Never rely on defaults or implicit casting. If the column needs an index, add it in a separate migration to reduce lock time.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast for most data types, but large defaults can be costly. Add the column as nullable, backfill data in small batches, then enforce NOT NULL if needed. In MySQL, use ALGORITHM=INPLACE when possible to avoid table rebuilds.