The table was live, query traffic streaming in, and the request came: add a new column. No downtime. No broken code. No missing data.
A new column in a production database can be trivial or dangerous, depending on how you do it. The wrong move locks tables, stalls writes, and triggers alerts. The right move keeps performance steady while introducing new capabilities to your schema.
When adding a new column, first know your database’s behavior. In PostgreSQL, adding a nullable column without a default is fast—it only updates the catalog. But adding a column with a default rewrites the entire table. In MySQL, certain ALTER TABLE operations are instant, but others cause full table copies. In cloud-managed services, behavior can differ with each engine version.
Plan for safe deployment. Use migrations that are explicit and reversible. In systems like Liquibase or Flyway, define the new column with types and constraints, but avoid backfilling in the same transaction. Backfill in batches to reduce lock times and write pressure. Add indexes only after the column is populated if you need them.