The database schema was perfect until the product team asked for a new field. You need a new column, and you need it without taking the system down. The migration has to be safe, fast, and reversible. The data must stay consistent.
Adding a new column can be dangerous in production. Long table locks slow requests. Large datasets can make a schema change run for hours. A simple mistake can corrupt data or block writes. That’s why a disciplined approach matters.
Start with a migration plan. Define the new column with clear type and constraints. Decide if it needs a default value or if it can be null. Defaults can lock the table on creation, so consider adding the column first and backfilling in batches.
In PostgreSQL, ALTER TABLE ... ADD COLUMN is straightforward but can still hold locks. In MySQL, use ALGORITHM=INPLACE or ONLINE if your engine supports it. For massive tables, run schema changes during low traffic hours, or use online migration tools like pt-online-schema-change or gh-ost.