Adding a new column is one of the most common database changes, yet it’s also one of the most error-prone. Done wrong, it slows queries, locks tables, and breaks downstream code. Done right, it ships to production without a ripple.
Start by defining the column in your migration script. Use explicit types, not defaults. If you need a boolean, store it as a tinyint or boolean type native to your database, not as text. Name it with intent. Column names live for years and get read more than they get written.
For large tables, add the new column without a default first. Populate data in controlled batches to avoid locking. In MySQL, avoid operations that force a full table rebuild when uptime matters. In PostgreSQL, most ADD COLUMN operations are fast for nullable fields, but defaults with non-constant expressions trigger table rewrites.
Ensure the application layer can handle null values before deploying. Rolling out a non-null constraint later is safer than blocking writes on day one.