Adding a new column sounds trivial. In most databases, it is a simple ALTER TABLE statement. But in production systems, the risks stack fast: blocking writes, long lock times, schema drift, and deployment races. A single misstep can take down a live service.
When creating a new column in SQL, your choices matter. In PostgreSQL, adding a column with a default non-null value rewrites the entire table. That’s acceptable for small datasets but dangerous for terabytes of data under load. Use nullable columns first, backfill in chunks, then set the constraint. MySQL, on the other hand, can add columns online in certain storage engines, but only under specific configurations.
Schema changes need to be safe, observable, and reversible. Wrapping the new column in feature flags isolates it from user-facing code until fully populated. Deploying the application to read from both the old and new fields during backfill prevents surprises. Automated database migration tools can help, but they must be integrated into CI/CD pipelines with rollback strategies in place.