Adding a new column sounds simple. It is not. The wrong approach can lock tables, trigger downtime, or corrupt data. The right approach depends on your database, schema size, and deployment constraints.
First, plan the schema change. In PostgreSQL, use ALTER TABLE ADD COLUMN for fast, non-blocking additions if the column is nullable and has no default. Adding a column with a default value writes to every row. On large tables, that can be slow and dangerous. Instead, add the column as nullable, backfill in batches, then set defaults and constraints.
In MySQL, ALTER TABLE can lock writes. For production systems, consider pt-online-schema-change or native online DDL options for InnoDB. Test these operations in a staging environment with realistic data volumes.
When introducing a new column, update your application code in steps. Deploy the schema change first. Only start writing to the column once it exists everywhere. Reads should tolerate nulls until the backfill finishes. Avoid combining schema changes and code changes into one deployment.