The database was ready, but the data model needed change. A new column had to be added—fast, safe, and without downtime.
A new column in a table sounds simple. In production, it can be the difference between shipping and breaking the system. Schema changes affect storage, query performance, and replication. They require precision.
When you add a new column, decide its type and constraints before touching the database. Choose defaults with care—backfilling millions of rows can lock tables or degrade throughput. Test migrations against realistic data sizes. Monitor locks and execution plans.
In PostgreSQL, ALTER TABLE ADD COLUMN is the basic command. By default, adding a nullable column is fast, but adding a column with a non-null default can rewrite the table. MySQL behaves differently; upgrading large datasets may require online schema change tools like gh-ost or pt-online-schema-change to avoid blocking writes. In distributed systems, propagate column changes through migrations in code and update every service using that table.