The database groaned when we hit the migration. We needed a new column, and it had to be fast, safe, and clean. No downtime. No lost data. No broken queries.
Adding a new column sounds simple. It never is. A schema change in production runs through every query, every index, every transaction. The wrong move creates locks that stall writes, block reads, and push latency through the roof. The right approach keeps the system online, consistent, and ready for the next deploy.
First: define the column with precision. Choose the right data type, constraints, and defaults. Avoid nullability unless necessary; null checks slow reads and increase complexity.
Second: plan the migration strategy. For small tables, a straight ALTER TABLE ADD COLUMN often works. For large or high-traffic tables, use an online schema change tool or perform a rolling migration: