Adding a new column seems simple until it’s not. Schemas define your application’s truth. One extra column changes writes, reads, indexes, and migrations. In a small table, the ALTER TABLE command runs instantly. In a large production table, it can lock rows for minutes or hours. The wrong approach can stall an API, block a queue, or take down a service.
There are two main paths: online schema change tools and versioned migrations. Tools like pt-online-schema-change or gh-ost work by copying data row by row and swapping tables in place. They reduce locks but increase load. Versioned migrations, common in ORM frameworks, treat the change as a code artifact. Every deploy runs the same migration against a known state.
For new columns, choose defaults carefully. Without a default, existing rows hold NULL. With a default, especially non-null, the database may rewrite the entire table. For high-traffic systems, add the column with NULL allowed first, backfill in small batches, then enforce NOT NULL after validation. This avoids table rewrites under transactional locks.