Adding a new column to a database table sounds simple. In practice, it touches schema, code, and production data. Done wrong, it blocks deploys, breaks queries, and corrupts state. Done right, it’s invisible to users and safe under full traffic.
A new column starts with a schema change. In SQL, that’s ALTER TABLE ... ADD COLUMN. In most relational databases, this is an atomic change for empty columns with defaults, but it can lock the table. On PostgreSQL, for example, adding a column without a default is instant, but adding one with a non-null default rewrites the table. That rewrite can take minutes or hours. Avoid heavy locks by adding the column as nullable, backfilling in batches, and then applying the NOT NULL constraint.
Application code must handle the existence of the column gracefully. When rolling out, deploy schema changes first, then code that writes to the column, then code that reads from it. This staged approach avoids null reference errors and data mismatches. Feature flags can control write paths during the migration.