Adding a new column is one of the most common schema changes in any database, yet it’s often the change most likely to halt production if done wrong. Whether in PostgreSQL, MySQL, MariaDB, or any other SQL database, the decision is simple but the execution is not. The wrong migration can lock tables, spike load, and trigger downtime.
A new column can be for better indexing, feature flags, telemetry, or security data. The process starts with clarity: define the column name, type, constraints, and default value before touching the schema. Avoid adding defaults with large writes on existing rows in high-traffic systems; this can cause a full table rewrite. Instead, add the column as nullable, backfill in batches, and then set constraints when safe.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast for empty or nullable additions, but costs rise with default values. In MySQL, ALTER TABLE often rebuilds the entire table, so test it in staging and consider ALGORITHM=INPLACE or ONLINE options if supported. Always wrap changes in migrations that can roll forward and backward without data loss.