Adding a new column to a production database should be simple. It rarely is. Schema changes carry risk: downtime, data loss, and blocked writes. The right approach balances speed with safety, especially when dealing with high-traffic systems.
First, determine the exact column definition. Name it clearly, choose the right data type, and set default values only when necessary. Avoid adding non-null constraints until the column is fully backfilled.
Second, make schema changes backward compatible. Add the new column before the application uses it. Deploy the application code that reads and writes the column only after the schema is in place and stable. This sequence prevents rolling deploy issues and read/write mismatches.
Third, plan the data backfill. For large tables, run background jobs in batches to avoid locking and performance degradation. Monitor replication lag and query latency closely during the process.