The database was ready. The logic was sound. But the schema had to change. A new column stood between deployment and downtime.
Adding a new column should be simple. In practice, it can trigger locks, block queries, and stall critical processes. The key is to plan for it, execute in the right order, and avoid surprises in production.
Start by identifying the exact column type and constraints. Avoid defaults that require backfilling large tables in a single transaction. Instead, create the column as nullable, then populate it in small, controlled batches. This reduces write contention and keeps the application responsive.
In PostgreSQL, ALTER TABLE ADD COLUMN is usually fast for empty columns without defaults. In MySQL, large tables may still lock depending on the storage engine version. Always confirm behavior in a staging environment with realistic data volumes. Benchmark migration scripts before release.