Adding a new column sounds simple. In reality, it tests the infrastructure and the process. Schema migrations must be precise. A single mistake can lock rows, slow queries, or block writes.
Start with the migration file. Define the new column with its type, constraints, and default values. Avoid setting NOT NULL without a default on large tables—you’ll trigger a full table rewrite. Use NULL first, then backfill data in small batches. After backfilling, alter the column to NOT NULL if required.
For PostgreSQL, add columns with ALTER TABLE ... ADD COLUMN for fast changes. This is almost instant for empty defaults. MySQL and other relational systems differ in cost for adding columns, so check execution plans and locks before running in production. With cloud databases, changes propagate through replicas and need careful rollout.