The migration script was running fine until it hit the table that wouldn’t bend. You needed a new column, but the clock was ticking and the schema was already in production. This is where mistakes become outages.
Adding a new column in SQL sounds simple. In practice, it can lock tables, block writes, and send latency through the roof if handled carelessly. The core command is straightforward:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
But production databases demand care. Before you add a column, review the table size, existing indexes, replication lag, and operational load. On large datasets, schema changes can create downtime unless you use online DDL tools or versioned migrations.
For MySQL, tools like pt-online-schema-change or native ALTER TABLE ... ALGORITHM=INPLACE can avoid blocking writes. PostgreSQL can add nullable columns instantly, but adding a column with a default value rewrites the entire table unless you use DEFAULT NULL first, then backfill in small batches.