The schema was live for less than an hour before the first request came in: add a new column. No debate, no delay. The database needed to evolve, and it needed to happen without downtime.
Adding a new column sounds simple. In production, it can be a fault line. The wrong migration locks tables, drops performance, or corrupts data. The right approach depends on your database engine, data size, and traffic patterns.
For PostgreSQL, ALTER TABLE ... ADD COLUMN is fast when the column is nullable with no default. The definition updates metadata only—no table rewrite. Adding a default value forces a rewrite and can block queries. To avoid this, add the column as nullable, then backfill its values in batches. After backfilling, set the default and mark it NOT NULL.
In MySQL, ALTER TABLE often copies the entire table. On large datasets, this is expensive. Use tools like pt-online-schema-change or gh-ost to apply schema changes incrementally, keeping the table accessible during the migration.