The migration was done, but the data looked wrong. The fix was obvious: a new column.
Adding a new column sounds trivial. In production, it’s not. Wrong steps can lock a table, throttle performance, or break dependent services. The right approach reduces downtime and risk.
Start by defining the column with explicit types and defaults. Avoid implicit conversions. Every byte matters when scaling across millions of rows. In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward, but setting a NOT NULL with default on large tables can block writes. Use a two-step process: add the column as nullable, backfill in batches, then enforce constraints.
For MySQL, the storage engine affects how a new column is added. InnoDB can rebuild the table internally, which impacts I/O. Consider online DDL features (ALGORITHM=INPLACE) to limit locking. For distributed databases, adding a new column may require schema replication and careful version handling across services.