Adding a new column should be simple. In practice, it can trigger deployment delays, long locks, or silent data bugs. The right approach depends on your database engine, your migration tools, and the scale of your tables.
In PostgreSQL, adding a nullable column with a default can lock writes longer than expected, especially on large datasets. A safer method is to add the column without the default, backfill in batches, then apply the default and constraints after the data is ready. This three-step process minimizes downtime while maintaining integrity.
In MySQL, ALTER TABLE can rebuild the entire table. On large tables, that means minutes or hours of blocking. Tools like pt-online-schema-change or gh-ost let you create the new column online, syncing data in the background before a fast final cutover.
When using ORMs, a new column in the model won’t help if the migration is wrong. Review generated SQL. Strip away unnecessary defaults on creation. Test on a production-sized copy, not just in development.