Adding a new column sounds simple. It is not. In production systems, schema changes ripple through APIs, batch jobs, cache layers, and every query that touches the table. A careless change risks downtime, data loss, or silent corruption.
The first step is to define the new column with precision. Decide the data type. Set NULL or NOT NULL. Choose a default value only if it will not mask data issues. Avoid using generic names; the schema must speak clearly to any engineer reading it.
Plan the migration. For large tables, use online schema change tools like gh-ost or pt-online-schema-change. Break the change into safe stages. Add the column first. Backfill in small batches. Add indexes in a separate transaction. Test each step on a staging environment identical to production.
Update application code to handle the new column without assuming it will always have data. Deploy code that writes to and reads from the column before running cleanup scripts. This reduces race conditions and allows for rollback if needed.