The query ran. The data came back. Now you realize you need a new column.
Adding a new column sounds simple. It’s not. Schema changes can be the fastest way to break production or slow down every query in your system. The wrong approach locks tables, blocks writes, and risks downtime. The right approach deploys fast, with zero interruption, and is easy to roll back.
First, define the new column with the exact type and constraints you need. Decide if it allows NULLs, has a default, or must be indexed. Never add an index blindly—measure the impact.
Second, pick the migration method that matches your database. For PostgreSQL, ALTER TABLE is often safe for a new nullable column. For large MySQL tables, use online schema change tools to avoid blocking writes. For distributed systems, run migrations in stages: add the column, backfill in small batches, then enforce constraints.