Adding a new column can be trivial or it can bring an application to a halt. The difference lies in how you handle schema changes in production. A careless ALTER TABLE can lock rows, delay queries, and block writes. A well-planned approach avoids disruption.
Start with clarity on the column definition. Decide the data type, nullability, default values, and constraints before writing the migration. Changing these later can trigger expensive table rewrites. Use explicit naming that survives refactors and avoids future collisions.
For large tables, choose a method that minimizes locking. Online schema change tools such as pt-online-schema-change or gh-ost can add a new column without blocking traffic. In PostgreSQL, adding a nullable column with no default is usually fast, but adding a non-null column with a default can rewrite the entire table. Break this into steps: first add the column as nullable, then backfill values in batches, and finally set the NOT NULL constraint.