The schema was locked. The business needed a change. The team stared at the migration script, and the question was simple: how to add a new column without breaking production.
Adding a new column to a database table sounds routine. It is not. The decision touches performance, data integrity, and deployment safety. A rushed ALTER TABLE can lock rows, block queries, or trigger downtime. Done right, it becomes a seamless extension of your schema.
First, define the column explicitly. Name it for clarity, type it for accuracy, and set constraints only if they will not block inserts during rollout. Avoid default values that force a table rewrite on large datasets. For many systems, adding a nullable column first is safest, followed by a migration to populate and enforce constraints if needed.
Second, plan the migration path. In PostgreSQL, ALTER TABLE ADD COLUMN is fast for nullable, unconstrained fields. In MySQL, the impact depends on the storage engine and version, with some changes causing a full table copy. Test in a staging environment with production-like data to measure execution time.