Adding a new column is one of the most common database migrations. Yet, it is often where teams introduce downtime, data loss, or schema drift. A clean migration process is critical, whether you use Postgres, MySQL, or another SQL database. The principle is simple: define the schema change, apply it safely, and keep application code in sync.
First, choose the right column type. Avoid guessing. For large datasets, altering column types later can lock tables and block writes. Decide on constraints and nullability before running your migration. If the column must be non-nullable, in many cases you should create it as nullable first, backfill data, then apply a constraint in a second step.
Next, use an atomic migration tool or run SQL in a transaction when supported. This ensures the new column appears at once rather than midway through queries. For production systems under heavy load, apply changes during a maintenance window if the database engine locks writes for DDL statements.