The table is broken, and you know why. It needs a new column.
Adding a new column sounds simple. In practice, it can trigger downtime, lock tables, break code paths, and wreck deploy schedules. Schema changes are one of the highest-risk operations in a database. A careless migration can stall queries, block writes, or corrupt data. The key is planning the new column so it’s safe, fast, and backward-compatible.
Start by defining the column exactly. Use the smallest data type that holds the intended values. Avoid NULL defaults unless they’re part of the design. Adding a new column with a default value can cause the database to rewrite the entire table. This can cripple production. If you must set a default, do it in a separate step from the initial creation.
Run the migration on a staging environment with real-size data. Watch for locking behavior. In PostgreSQL, ALTER TABLE ADD COLUMN is usually fast, but adding with a default will rewrite. In MySQL, older versions perform full table copies; newer editions handle it faster, but check the engine and version. Foreign keys, indexes, and triggers can all change the migration cost.