The database was running fine until you tried to ship a new feature. Then someone said, “We need a new column.”
Adding a new column sounds simple. In reality, it can break queries, stall deployments, and corrupt data if done without care. Schema changes are one of the most dangerous operations in production systems, especially under real user traffic.
A new column changes the shape of your data. Adding it to a table with millions of rows can trigger a full table rewrite or lock. In PostgreSQL, ALTER TABLE ADD COLUMN is fast if you use a default of NULL, but slow and blocking if you set a non-null default. In MySQL, adding a column to large InnoDB tables may require rebuilding the table. These differences matter when you’re shipping without downtime.
Plan the column’s data type, nullability, and default values before making the change. Backfill data asynchronously instead of in one migration. If the system is high-traffic, use online schema change tools or run migrations in small batches. Test performance by cloning production data into a staging database first.