Adding a new column to a database table seems simple. It is not. Migrations can lock tables, block writes, and drop performance to zero. If you ship during peak traffic, you might take the system down. The right approach depends on size, traffic, and query patterns. The wrong approach can corrupt data or stall the app.
Start by deciding how the new column will be used. If it must be non-nullable, add it as nullable first. Backfill data in small batches to avoid overwhelming replicas. Create indexes after the table is populated, not during the initial migration. This prevents long locks and reduces the chance of cascading delays.
When dealing with large datasets, use online schema change tools like gh-ost or pt-online-schema-change. They clone the table in the background and apply changes incrementally. This lets reads and writes continue while the schema is updated. Monitor replication lag and error rates before, during, and after the migration.