The table was running in production when the requirement dropped: new column. No migration plan. No downtime allowed. Just the need to store more data and make it available immediately.
Adding a new column is one of the most common schema changes. Done wrong, it can lock tables, block writes, and spike latency. Done right, it can be invisible to users and safe for critical workloads.
The process begins with understanding the database engine. In PostgreSQL, ALTER TABLE ADD COLUMN can be fast if the new column has no default value and allows NULLs. MySQL behaves differently, with performance dependent on storage engine and table size. For massive tables, online schema change tools like gh-ost or pt-online-schema-change can add a column without blocking queries.
Always check for implicit locks. Even when adding a nullable column, certain configurations or indexes can trigger a rewrite. Monitor memory, I/O, and replication lag during the change. In distributed systems, apply migrations incrementally, and keep application code backward compatible until the column is fully in place.