Adding a new column should be simple. In practice, it can be a minefield—downtime, failed writes, silent nulls creeping into production. The right approach depends on your database engine, your traffic profile, and your deployment pipeline. Get it wrong and you risk locking tables or corrupting data.
Start by defining the new column with safe defaults. Avoid backfilling inline on large tables. Run ALTER TABLE commands in small, controlled steps, or use an online schema change tool. Test the entire process in a staging environment with production-sized data.
If your application is live, add the new column in a non-blocking manner. For Postgres, use ALTER TABLE ... ADD COLUMN with a default only if it is computed on read, or backfill in batches. For MySQL, consider pt-online-schema-change to avoid table locks. After adding, deploy application code that can handle the column being present but empty. Backfill asynchronously. Only enforce constraints or non-null rules after the data is complete.