Adding a new column sounds simple. In production, it can be dangerous. Schema changes lock tables, block writes, or slow queries. Bad timing takes down your API. The way you add a column decides whether your users notice or not.
In PostgreSQL, ALTER TABLE ADD COLUMN is instant if it has no default and allows NULLs. Once you set a default or make it NOT NULL, the database must write to every row. That’s where downtime happens. MySQL handles this differently depending on storage engine and version, sometimes copying the whole table.
For large datasets, plan your migration in steps. First, add the column as NULL. Second, backfill in small batches. Then, enforce constraints and defaults. This avoids blocking writes and keeps read replicas healthy. Always monitor replication lag during the process.