Adding a new column is one of the most common schema changes. Done right, it’s fast, safe, and easy to deploy. Done wrong, it can halt a release, cause data corruption, or trigger downtime in production. The difference comes down to planning, execution, and understanding how your database handles schema migrations.
Start by defining the purpose of the column with precision. Name it clearly. Keep it consistent with existing naming conventions. Choose the smallest, most accurate data type possible. Avoid null values unless they are explicitly required. If defaults are needed, set them at the schema level to avoid unexpected writes in the application layer.
In PostgreSQL, adding a column with ALTER TABLE … ADD COLUMN is metadata-only when no default is defined, making it almost instant. But adding a default value to an existing table will rewrite the table and lock it, so consider a two-step migration: first add the column as nullable, then backfill asynchronously, and finally set the default.