The migration was going well until the schema changed. A new column appeared in the database. Everything downstream broke. Builds failed, pipelines stalled, and the production dashboard lit up red.
Adding a new column is simple in SQL. But in a real system, nothing is simple. The column must exist in the schema, the ORM models, the migrations, the API responses, and the analytics queries. If one part lags behind, you ship bugs or downtime.
First, confirm the column’s purpose and data type. Decide if it should allow nulls, have a default, or require a unique constraint. In PostgreSQL, you can add it with:
ALTER TABLE orders ADD COLUMN priority_level INTEGER DEFAULT 0;
In MySQL:
ALTER TABLE orders ADD priority_level INT DEFAULT 0;
Run these only in a controlled environment. For large tables, ALTER TABLE can lock writes. Consider creating the column as nullable, backfilling data in batches, and then applying constraints after.