Adding a new column to a production database is simple in code but risky in practice. Disk I/O spikes. Locks hold longer than planned. Every query touching that table feels it. The right approach avoids downtime, keeps writes safe, and ensures future changes stay clean.
Start by defining the new column in your migration tool of choice—Liquibase, Flyway, or a framework’s built-in system. Use a nullable column first, or set a safe default that doesn’t force a full table rewrite. In PostgreSQL, adding a column with a DEFAULT constant and no NOT NULL constraint is instant. In MySQL, avoid operations that rebuild the table unless you can handle the lock.
After deployment, backfill data in small batches. This prevents replication lag and avoids blocking reads. Use efficient indexing strategies; adding indexes after the column is populated can prevent massive write amplification during the backfill.