The schema was perfect until you realized it wasn’t. A new column had to exist.
Adding a new column sounds simple. It can be simple. But in production systems, simplicity dies if you choose the wrong path. The wrong migration. The wrong constraints. The wrong defaults.
First, define the purpose. Every new column must have a reason, an exact role in the dataset. Columns that collect half-measured data rot over time. Think about type safety. Integer or bigint? Text or varchar with length limits? Do not guess. Choose what matches usage and indexing.
Next, plan the migration. In relational databases, adding a column is a schema change. On small tables, it is instant. On massive tables, it can lock writes and consume memory. Use ALTER TABLE carefully. In PostgreSQL, adding a nullable column without a default is fast. Adding a default value requires a table rewrite. Avoid downtime by splitting steps: create the column, backfill data in batches, then add constraints.