Most feature-flag advice treats flags as a UI concern — show a button to 10% of users, measure, ramp up. That mental model falls apart the moment the flag is sitting in front of a data migration. A UI flag can be flipped back instantly. A half-run backfill cannot. Once you've written new rows, dual-written to two tables, or started reading from a column that's only populated for 40% of records, "turn the flag off" doesn't put the data back.
The interesting problem isn't governance of the flag. It's what acceptance criteria prove the migration is safe to advance, and what signal is allowed to trigger a rollback before the data gets into a state you can't walk back from.
This post is narrow on purpose. It's about feature flag data migration requirements specifically where a flag controls read/write paths against a schema that's mid-change, and where your rollback decision has to be driven by data consistency checks — not error rates or a PM's gut.
## The specific failure: a flag that rolls back the code but not the data
A payments team was moving invoices.customerref from a free-text column to a normalized customerid foreign key. Standard expand-migrate-contract. They put the new read path behind a flag called usenormalizedcustomer.
Here's the sequence that actually happened:
-
Deploy with dual-write on. New writes populate both
customerrefandcustomerid. -
Run a backfill to populate
customer_idfor the ~2.1M existing rows. -
Flip
usenormalizedcustomerto read fromcustomer_idat 25%. -
Error dashboard looks clean. Latency looks clean. Ramp to 100%.
The problem: the backfill had a join condition that silently dropped rows where the free-text customer name had a trailing whitespace or a casing mismatch. About 3% of invoices — roughly 63,000 records — ended up with a NULL customer_id. The read path returned "customer not found" for those, but the app degraded gracefully and showed a blank customer field instead of throwing. No errors. No latency spike. The dashboard governing the flag ramp had no idea anything was wrong.
Finance found out four days later when they couldn't reconcile a batch of invoices. By then the contract phase had dropped customer_ref, so the original data was gone. Recovery meant pulling from backups and replaying four days of writes.
The flag worked perfectly. The flag governance was fine. The acceptance criteria were measuring the wrong thing.
## Why error-rate gating lies to you during migrations
When you gate a normal feature on error rate, you're assuming that if the feature is broken, something will throw. Data migrations break that assumption constantly, because the most dangerous migration bugs are silent: a row that's missing, a value that's subtly wrong, two tables that disagree.
Stop losing track of critical project requirements.
GoReqly helps you capture, organize, and track every requirement with precision and clarity.
- Centralized requirements repository
- Collaborative editing & commenting
- Traceability & version control
No credit card required
This usually happens for three reasons:
-
Graceful degradation hides the gap. Good apps don't crash on a missing join; they render empty. That's exactly what defeats error-based gating.
-
The backfill and the live write path diverge. Your dual-write logic and your one-time backfill script are two different pieces of code. They almost never agree on edge cases — nulls, encoding, timezone handling, rounding.
-
Sampling bias in the ramp. A 25% rollout usually samples by user or request, not by data age. Your newest rows (which have clean dual-writes) look fine, while the old backfilled rows — where the real risk lives — aren't proportionally represented in what the flag is exercising.
The fix isn't a better dashboard. It's changing what the gate checks from "are requests failing" to "do the two representations of this data agree."
## Acceptance criteria that actually gate a migration
The acceptance criterion for a migration flag should be a consistency assertion, expressed as a query that returns zero rows when things are correct. If it returns anything, the gate fails and the ramp stops — or reverses.
Here's the consistency verifier the payments team should have had running before any ramp:
-- Verifier: every invoice with a customerref must have a resolvable customerid -- Expected result: 0 rows. Any rows = migration not safe to advance. SELECT i.id, i.customerref, i.customerid FROM invoices i WHERE i.customerref IS NOT NULL AND (i.customerid IS NULL OR NOT EXISTS (SELECT 1 FROM customers c WHERE c.id = i.customer_id));
Notice what this does that an error dashboard can't: it checks both sides agree across the entire table, not just the rows that happened to get requested during the ramp window. Run it on a schedule during the rollout, and those 63,000 orphaned rows show up on the first execution — before you flip a single reader.
For the dual-write phase, you also want a drift verifier that catches the write paths disagreeing going forward:
-- Verifier: dual-write agreement on recently written rows -- Run every few minutes during the dual-write window. SELECT i.id, i.customerref, c.displayname AS resolvedname FROM invoices i JOIN customers c ON c.id = i.customerid WHERE i.createdat > now() - interval '15 minutes' AND lower(trim(i.customerref)) <> lower(trim(c.display_name));
The second query is the one that would have caught the whitespace/casing bug as it was happening, because it normalizes exactly the way the backfill failed to.
A good migration acceptance criterion has four properties:
-
Deterministic returns zero rows when correct, so the pass/fail is unambiguous.
-
Whole-population scans the full affected set, not a sampled slice.
-
Cheap enough to run repeatedly indexed, time-bounded, or run against a read replica so you can execute it every few minutes.
-
Mapped to a specific rollout stage the dual-write verifier and the read-switch verifier are different queries guarding different gates.
A simple diagram of the verifier-driven rollout workflow.
## Rollout windows that match what the data can tolerate
The second mistake is ramping on a schedule that ignores how reversible each stage actually is. The expand-migrate-contract phases have very different rollback costs, and your rollout window should reflect that.
| Stage | What the flag controls | Rollback cost if wrong | Gate before advancing |
|---|---|---|---|
| Dual-write on | New writes hit both old and new | Low — stop writing new column | Drift verifier clean for full window |
| Backfill running | One-time population of existing rows | Low — rerun backfill | Orphan verifier returns 0 rows |
| Read switch (ramp) | App reads from new column | Medium — flip reader back | Consistency verifier clean at each % step |
| Contract | Old column dropped | Irreversible — data is gone | Everything green + hold window elapsed |
The rule that keeps teams out of trouble: never contract on the same day you finish ramping. Put a mandatory hold window — at least a few days — between hitting 100% reads and dropping the old column. The invoices team contracted too fast, which turned a recoverable "flip the reader back" situation into a backup-restore incident.
The read-switch ramp should advance on verifier results, not on a clock. A sensible pattern:
-
Hold at 10% until the consistency verifier has run clean across at least one full business cycle — so you capture batch jobs, nightly processes, reporting queries, all the things that only touch data at certain hours.
-
Advance to 50% only after the orphan verifier confirms zero null/unresolvable rows and the drift verifier has been clean for the entire 10% window.
-
Advance to 100% after 50% holds clean through another business cycle.
-
Stop. Do not contract. Start the hold window.
The invoices team contracted too fast, which turned a recoverable "flip the reader back" situation into a backup-restore incident.
## Mandatory evidence bundles feeding the release gate
This is the part most teams skip: verifier results need to be captured as evidence, not just glanced at on a dashboard and forgotten. The release gate that allows the contract phase should require an evidence bundle proving every prior gate passed — with timestamps and query output attached.
A migration evidence bundle for the contract gate should contain:
-
The orphan verifier output (showing
0 rows) with the exact timestamp of the run and the row count of the table it scanned. -
The drift verifier results across the full dual-write window, not just the last run.
-
The consistency verifier output at each ramp percentage, each tied to the flag state at that time.
-
The backfill job log with final counts
rows attempted, rows updated, rows skipped. (Skipped > 0 is itself a gate failure — one the invoices team ignored.)
-
A signed confirmation that the hold window elapsed before the contract ran.
This is the same discipline described in building automated release evidence bundles, applied to the specific case of a schema change. The bundle isn't bureaucracy — it's how you answer "was it safe to drop that column?" with evidence instead of memory. And when a migration does go wrong, the bundle tells you exactly which gate the bad data slipped past.
The practical wiring: your verifiers run as scheduled jobs (or as CI checks against a replica), their output gets written to an artifact store keyed by flag name and rollout stage, and the contract-phase release gate refuses to proceed unless the required artifacts exist and show passing results. That mirrors the approach of automating requirement-to-test links with CI hooks — the gate checks for linked evidence, not a human's assertion that the check was done.
## A real scenario with numbers
A mid-sized B2B SaaS running appointment scheduling was splitting a monolithic bookings table — moving recurring-appointment rules out into a separate recurrence_rules table. Around 480,000 existing bookings, roughly 70,000 of which had recurrence data embedded in a JSON blob.
Their first attempt mirrored the invoices failure: ramped the read flag on error rate, found out two weeks later that about 1,900 recurring bookings had lost their end-date because the JSON parser handled a legacy format differently than the live code. Support tickets — not alerts — surfaced it. Recovery took the better part of a week and cost a lot of trust with their larger customers.
On the rebuild, they gated differently. A consistency verifier compared the parsed recurrence_rules rows against the original JSON blob (kept during the expand phase) and asserted the computed end-dates matched. It ran every 10 minutes against a replica throughout the rollout.
The verifier caught the legacy-format bug during the backfill itself — before any reader was switched. The orphan count came back at around 1,850 rows on the first run. They fixed the parser, reran the backfill, got a clean zero, and only then started the read ramp. Ramp-to-contract took about nine days instead of their original two, but there were no support tickets and no restore. The extra week was cheaper than one afternoon of the previous incident.
## When this level of gating makes sense — and when it's overkill
Do this when: the migration touches a table you can't easily rebuild from another source, when the contract phase is destructive, or when downstream systems — billing, reporting, exports — read the affected columns. Anything financial or customer-facing belongs here.
It's overkill when: you're backfilling a derived column you can recompute from source at any time, or migrating a cache or materialized view that regenerates on its own. If "rollback" genuinely means "rerun a script and you're back to correct," you don't need consistency gates — you need a rerun button.
Who should not lean on this: very early-stage products with tiny datasets where a full table scan takes milliseconds and the whole migration fits in a single transaction. If you can wrap the migration in one transaction and roll it back atomically, staged verifiers add ceremony you don't need yet. These patterns earn their keep once your data is big enough that migrations have to run outside a single transaction — which is exactly when silent partial failures become possible.
A feature flag in front of a data migration is not protecting you the way a feature flag in front of a button is. The code path is reversible; the data state frequently is not. That means the gate has to be anchored to a consistency assertion over the whole affected population — a query that returns zero rows when the two representations of your data agree — and the ramp has to advance on that signal, not on error rates or elapsed time.
Capture each verifier run as evidence, hold before you contract, and make the irreversible step require proof that every reversible step came back clean. Get that right and the flag does what you actually wanted it to do: not just switch a code path, but refuse to let bad data become the only version you have left.
Ready to transform your product delivery?
Join 2,000+ teams using GoReqly to improve requirements accuracy, reduce rework, and accelerate time to market.