The table schema changed at midnight. By morning, the team needed a new column in production without downtime, without breaking queries, and without corrupting data.
A new column sounds simple, but it is not. The wrong approach locks tables, blocks writes, and stalls the application. The right approach adds the field with zero disruption and keeps the migration predictable.
In most relational databases, adding a new column is a Data Definition Language (DDL) operation. In systems like PostgreSQL, adding a nullable column with a default can rewrite the entire table, which grows expensive as the dataset scales. One safe pattern is to add the column without a default, backfill data in controlled batches, then set the default. This avoids long locks and replication lag.
For MySQL, ALTER TABLE ADD COLUMN can be instant or blocking depending on the storage engine, indexes, and whether the column is nullable. Check the engine documentation before running migrations in production. Wherever possible, make schema changes online and test them in an identical staging environment.