The schema was locked, but you needed one more field. You opened the migration file and typed it: ALTER TABLE users ADD COLUMN last_login TIMESTAMP;. The build ran. The deploy was live. It was fast, but it could have been faster.
Adding a new column is one of the most common but critical database changes. When done right, it’s clean and safe. When done wrong, it can block writes, lock tables, or break production. The process is simple, but the details matter.
First, identify the exact column definition. Set the correct data type, default value, and constraints based on the data model. Use nullable columns for backward compatibility during rollout. Avoid wide default values that force large writes on creation.
Second, plan for zero-downtime migrations. In relational databases like PostgreSQL or MySQL, adding a column with a default can cause a full table rewrite. Instead, create it without defaults, then backfill in small batches. This keeps the operation safe under load.