Adding a new column sounds trivial. It can be simple. But in production systems, the wrong approach risks downtime, data loss, or schema drift. The goal is to create a new column in a way that is safe, performant, and easy to maintain.
First, define the purpose. Decide on the column name, data type, constraints, and whether it allows null values. For high-traffic systems, choose defaults carefully. Adding a column with a default constraint may lock writes on some databases. In PostgreSQL, adding a column without a default is instant. Then backfill in small batches to avoid long locks.
Second, coordinate migrations with the application layer. Deploy code that can handle both the old and new schema. This ensures safe rollouts and rollbacks. Use feature flags to switch behavior gradually.