Adding a new column in production is simple in theory. In practice, it touches performance, compatibility, and deployment safety. The wrong migration can lock a table, block writes, or break upstream services.
Start by defining the reason for the new column. Is it for a feature flag, a metrics counter, or a new user property? Pinpoint the type, default value, and constraints. Use migrations that are reversible. Commit changes that maintain backward compatibility until all dependent services are updated.
For relational databases like PostgreSQL and MySQL, ALTER TABLE ... ADD COLUMN is standard. For large tables, avoid locking by adding columns without defaults, then updating in small batches. In PostgreSQL, adding a nullable column without a default is an O(1) operation. Afterward, fill data asynchronously to prevent blocking queries.
Coordinate schema changes with application code updates. Maintain parallel read/write logic until the new column is fully populated. Monitor indexes — do not create them on massive tables in a single transaction during peak load.