Adding a new column should be simple, but in production systems, it can be risky. Schema changes can lock tables, break queries, or disrupt running services. The goal is to extend capability without downtime or corrupted data.
In SQL, creating a new column is straightforward:
ALTER TABLE orders ADD COLUMN status VARCHAR(20);
This works for small tables. For large datasets, performance and concurrency matter. Blocking writes while adding a column can cascade into outages. Use online DDL operations when possible. MySQL offers ALGORITHM=INPLACE or ALGORITHM=INSTANT for certain changes. PostgreSQL can add nullable columns without rewriting data, but adding defaults requires caution.
A schema migration should be automated, versioned, and reversible. Tools like Liquibase, Flyway, or Rails migrations track changes across environments. Rollouts should be staged. Deploy the new column first, then update the application code to use it. This avoids race conditions when some services read the new schema and others do not.