Adding a new column to a database should be routine, but the wrong approach can trigger downtime, lock tables, or break code paths that depend on old schemas. The key is to design the schema change precisely, deploy it safely, and ensure the application logic accounts for it end-to-end.
First, define the new column in a way that does not block writes. In PostgreSQL, adding a nullable column without a default is near-instant. Adding a column with a default value will rewrite the entire table, which can be a disaster on large datasets. Instead, add the new column as nullable, backfill in controlled batches, and then set defaults or constraints after the data is in place.
Second, keep application compatibility in mind. Code should handle both the pre-change and post-change schema during rollout. Feature flags help control when the new column becomes active. Avoid deploying code that immediately relies on a new column unless the schema is already live in production.