Adding a new column to a production database sounds easy until it isn’t. Schema changes carry risk. They can lock tables, spike CPU, break API contracts, or cause replication lag. A bad deployment here can slow queries for every user in your system.
Plan the new column before touching the database. Select a data type that fits the expected values without wasting storage or forcing future migrations. Define nullability and defaults explicitly. Even if the ORM generates migrations, inspect the SQL it runs. Avoid surprises.
For large tables, add the column in a way that avoids long locks. In Postgres, adding a nullable column without a default is near-instant. Adding it with a default rewrites the table. For MySQL, check if your storage engine and version support instant DDL. If not, consider an online schema change tool like pt-online-schema-change or gh-ost.
If you need to backfill data into the new column, do it in batches. Throttle updates to reduce replication lag. Monitor the change in metrics and logs. Treat the operation as a live deployment, not a static migration.