The table was slow, and the feature deadline was close. You needed a new column. Not later. Now.
Adding a new column sounds simple. In production, it can be a trap. Schema changes can lock rows, stall queries, and bring down API latency. The right approach keeps the database live, the code safe, and the release smooth.
Start by defining the new column with ALTER TABLE in a safe migration. Always set a default value and decide if the column can be NULL. If the column is large or requires data backfill, split the process into two migrations: first add the column, then process the data in batches. This avoids long locks and reduces the chance of deadlocks.
Test the migration on a staging environment with production-like data. Measure execution time. Watch for slow queries in logs or metrics. Keep migrations idempotent so they can be retried safely.