The query was slow. You checked the table. The schema was fine until you saw it: a missing new column.
Adding a new column is more than an ALTER TABLE command. It is a schema change that can lock rows, block writes, or break application logic if done without care. In modern systems with continuous traffic, you cannot afford blocking migration steps. The approach must be safe, fast, and reversible.
Plan the new column addition in stages. First, add the column with a default of NULL. This creates it without recalculating values for existing rows, which keeps the operation fast. Use a non-blocking migration framework when possible. Avoid adding constraints or indexes during this step.
Populate the new column in small batches. Write a background job to backfill data without locking the table for long periods. Monitor query plans and database metrics during this phase. Pause if replication lag increases or CPU spikes.