Schema changes are simple in theory. In production, they are dangerous. A poorly planned new column can lock tables, stall writes, and disrupt users. The key is to make the change without downtime and without corrupting data.
First, define the exact purpose of the new column. Avoid adding it “just in case.” Each column impacts storage, indexing, and query performance. Pick the right data type from the start. Use NULL defaults only if they make sense—default values can reduce migration complexity, but they can also bloat the table if not aligned with actual data needs.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast if no default is set. Adding a default forces a rewrite of the table in older versions. MySQL behaves differently: a new column may still lock the table unless you use ONLINE DDL or a migration tool like pt-online-schema-change.
For large datasets, split the change into phases. Add the column as nullable with no default. Backfill in batches, monitored for performance impact. Only after the backfill should you enforce NOT NULL constraints or apply indexes.