Adding a new column is simple in theory, but in production, the wrong approach can lock writes, stall queries, or even take down critical paths. Schema changes at scale demand precision. You can’t risk downtime or corrupted data.
A safe migration starts with assessing the table size and query load. On high-traffic systems, adding a column with a blocking ALTER TABLE is dangerous. Instead, use non-blocking migrations or methods supported by your database engine, such as ADD COLUMN with NOT NULL only after populating data in batches.
For PostgreSQL, ALTER TABLE ... ADD COLUMN is fast if the column allows null values. Adding a default with NOT NULL will rewrite the entire table and block writes. To avoid that, add the column without constraints, backfill data in controlled increments, then apply the constraint in a separate step.
In MySQL, large table changes can be made online with tools like gh-ost or pt-online-schema-change. These utilities create a shadow table with the new column, copy data in chunks, and switch over with minimal disruption. They also let you throttle changes to match system load.