Adding a new column in a live database can be safe, fast, and predictable—if you do it right. The details matter. Schema changes affect query plans, disk usage, and application logic. A careless migration risks downtime or data corruption.
Start with your migration strategy. In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward, but defaults and constraints can lock the table. In MySQL, a single ALTER can block writes unless you use ALGORITHM=INPLACE or ONLINE. Evaluate whether to backfill values in a separate step. This reduces lock contention and keeps your change deployable under load.
Think about nullability. Adding a NOT NULL column without a default forces an immediate full table rewrite. Consider allowing NULL first, then populating values, then enforcing NOT NULL in a later migration. This keeps the schema consistent while avoiding downtime.
For deployments, keep schema changes in source control. Version your migrations. Test them against production-like data. Use feature flags in the application layer so code paths tolerate the presence or absence of the column until rollout is complete.