The table is live. You need a new column, and it must be there before the next deploy. No migrations staged. No downtime tolerated.
A new column is one of the most common schema changes in production systems. It looks simple, but mistakes here can cascade. Data corruption. Locked writes. Stalled queries. Understanding how to add, index, and backfill a new column without breaking the flow is critical for high-velocity teams.
The first step is choosing the right data type. Match it exactly to its purpose. Storage overhead, indexing behavior, and query plans all depend on this choice. Adding a nullable column is fast. Adding a non-nullable column with a default will rewrite the entire table. Know the size of your dataset before you run the migration.
In PostgreSQL, ALTER TABLE ADD COLUMN is transactional. On small tables, it’s instant. On large ones, it can block. Zero-downtime migrations often add the new column as nullable first, then backfill in batches, then enforce constraints after the data is ready. MySQL behaves differently. Adding a column can be a table copy unless you use ALGORITHM=INPLACE where supported.