Adding a new column to a database table sounds simple. In production, it can be a minefield. Schema changes touch live data, slow queries, and risk downtime. Choosing the right approach means the difference between a smooth deploy and an incident review.
A new column changes storage layout and index behavior. On small tables, ALTER TABLE ADD COLUMN is instant. On large tables, it can lock writes or force a full table rewrite. That lock can block API calls, overflow queues, and trigger errors upstream. Always measure the size of the table before the change. Run the alter on a staging clone with identical data to see actual timing.
When you add a column, consider nullability and default values. Adding a NOT NULL column with a default can backfill the entire table, causing long locks. Adding it as nullable and then backfilling in batches avoids the rewrite. Use background jobs or migration scripts to update rows incrementally.
Indexes tied to the new column are a separate step. Create the column first, deploy, and backfill. Then create the index. Chaining it all in one migration increases lock time and risk. Splitting schema and data migrations keeps changes atomic and reversible.