The table was live in production, but the schema needed to grow. A new column had to exist—fast, safe, and without breaking anything.
Adding a new column is one of the most common schema changes in relational databases. It seems simple. It isn’t. Every production system has constraints: uptime, data integrity, migration speed, and compatibility with application code. A careless change can cause downtime, slow queries, or even corrupt data.
The right way to add a new column starts with the database you use. In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward, but the implications depend on the default values, nullability, and whether the column requires backfilling large datasets. In MySQL, adding a nullable column without a default can be instant in newer versions, but anything that rewrites the table will lock rows.
For high-traffic systems, schema migrations should be planned in phases. First, deploy the new column as nullable and without a default to avoid rewriting all rows. Next, deploy application changes that safely read and write the column. Finally, backfill data in small batches to avoid locking and load spikes. Tools like pt-online-schema-change for MySQL or pg_online_schema_change for PostgreSQL can help with zero-downtime migrations.