Adding a new column to a database table seems simple, but in production it is a live operation with real risk. The wrong approach can lock writes, trigger downtime, or cause silent data corruption. Proper handling starts with choosing the right migration strategy for your database engine and traffic profile.
For MySQL, ALTER TABLE with ADD COLUMN is straightforward for small tables, but large datasets demand an online schema change tool like gh-ost or pt-online-schema-change to avoid blocking queries. For PostgreSQL, adding a column without a default is near-instant. Adding one with a non-null default will rewrite the table, so it’s safer to set the default in a separate step.
Consider indexing. If the new column will participate in lookups or joins, create the index in a separate migration to reduce lock times. Test the migration path against a production-sized clone. Check replication lag on read replicas before applying changes globally.