The issue was simple: the data needed a new column, right now, without downtime and without risking corruption.
Adding a new column in modern databases is not a trivial change. It can lock tables, trigger long-running migrations, or break dependent systems if done carelessly. The best approach is to make it atomic, with a clear plan for schema evolution.
First, define the new column with explicit type and constraints. Avoid implicit defaults that cause full table rewrites. If the column is nullable, add it without a default to keep the operation fast. For non-nullable columns, backfill in batches after creation, then add the constraint.
Second, handle application code changes in phases. Deploy schema changes separately from the code that uses the new column. This prevents race conditions and ensures compatibility across rolling deploys. Use feature flags or conditional logic to preserve stability while the column is empty.
Third, index carefully. Adding an index at creation time can degrade performance. Postpone indexing until after data backfill, and prefer concurrent index creation if your database supports it.