The query came in fast: add a new column. No meetings. No debates. Just code.
A new column sounds simple, but it can define whether your database stays healthy or collapses under new demands. Schema changes can stall deployments, lock tables, or leak into production at the wrong time. The details matter.
First, decide if the new column will be nullable. Adding a NOT NULL column with no default will fail on non-empty tables. If you need defaults, consider their cost. Large tables will rewrite every row, which can block operations.
Next, think about indexing. Adding a new column is one thing; indexing it is another. Index creation on huge datasets can consume CPU, memory, and I/O. If the column will be part of a frequent WHERE clause or JOIN, plan the index as part of the migration, not an afterthought.
For PostgreSQL, use ALTER TABLE ... ADD COLUMN for most cases. To keep migrations safe, run them in steps. First, add the column without constraints or indexes. Then backfill the data in batches. Only after the backfill completes should you add constraints or indexes. This order minimizes locking and downtime.