The schema was final, the migrations deployed, but the product team asked for one more thing: a new column.
Adding a new column is simple until it isn’t. It starts as a quick change to a table. Then you realize it must work across dev, staging, and production without downtime. It must be compatible with old code and new code, and it must survive rollback.
In SQL, ALTER TABLE is the direct route to add a new column. With PostgreSQL, you can add it as nullable to avoid locking operations on large datasets, then backfill data in controlled batches. After the column is populated, enforce NOT NULL if required. In MySQL, beware full table locks for certain column changes, and consider ONLINE DDL features if available.
Plan the lifecycle of the new column. Introduce it in one release, populate it in background jobs, then switch reads to it in a later release. Remove old columns only when confident no code paths still depend on them. This phased approach avoids race conditions and broken queries.