The migration failed at 02:13. The logs showed one line that mattered: ERROR: column "status"does not exist. You knew then it was time to add a new column.
Creating a new column in a production database is simple in syntax, but never trivial in effect. The ALTER TABLE statement changes the shape of your data forever. In PostgreSQL, you run:
ALTER TABLE orders
ADD COLUMN status TEXT DEFAULT 'pending';
This instruction updates the schema without touching existing rows beyond setting defaults. In MySQL, the command is similar:
ALTER TABLE orders
ADD COLUMN status VARCHAR(50) DEFAULT 'pending';
The real challenge lies in planning. Adding a new column in a system under heavy traffic means considering locking, replication lag, and the risk of downtime. On very large tables, blocking writes for even a few seconds can break SLAs. Online schema change tools like pg_online_schema_change or gh-ost allow you to add columns to huge datasets with minimal disruption.