Adding a new column to a database should be simple. In practice, it can take down a service if done wrong. Schema changes touch live data, migration scripts, and application code. The stakes are high. Every step needs precision.
When you define a new column, decide on its type, default value, and constraints. A nullable column is easy to add but can lead to null checks everywhere. A NOT NULL column with defaults is safer for reads but requires careful backfilling. Always match the column definition to how the application will use it.
Plan your migration. For small datasets, a blocking ALTER TABLE might be fine. For high-traffic production systems, use online migrations or phased rollouts. Add the column, backfill data in batches, then add constraints once the data is consistent. Avoid locking large tables during peak load. Monitor the migration process and be ready to pause if replication lag spikes or queries slow.