BE-DP-32 · A night on the v1 copy with the drivers step
ID BE-DP-32 · Level L0 · Pack Row 5 · The domain steps · Run order row 5, on the drivers step's branch, before it merges · Issue #281
A night on your local stack, against the real v1 copy, runs master_data, vehicles and the drivers step, and reconciles them. The drivers step loads:
- one driver per v1 lead, on the stage D66, D73 and D78 give him;
- his SIM;
- his background checks;
- the queue tickets.
A lead it can't place is an unmatched row with its reason (R-MIG-04).
legacy and the loaded rows are a copy of v1's data in your local database: personal data, as the dump is (D15). The counts below are safe to post. The reconcile's lines and the unmatched rows name lead ids, so they stay on your Mac.
Before
Section titled “Before”- You are at the root of your clone, on the drivers step's branch (
be/281-drivers-step), aftergit pull,pnpm supabase db resetand BE-DP-07. The reset removesv1_live, so you link it again. docker ps --filter name=v1copylists the copy as Up.
1 · A run, its snapshot, and what's unmapped
Section titled “1 · A run, its snapshot, and what's unmapped”docker exec -i supabase_db_opleet psql -qX -U postgres -d postgres -v ON_ERROR_STOP=1 <<'SQL'select migration.begin_run('BE-DP-32, local, on the v1 copy, with drivers') as run;select migration.snapshot() as tables_copied;select domain, field, count(*) as values, sum(rows) as rows from migration.unmapped_values() group by 1, 2;SQL2 · The steps
Section titled “2 · The steps”docker exec -i supabase_db_opleet psql -qX -U postgres -d postgres -v ON_ERROR_STOP=1 <<'SQL'select migration.run('master_data') as master_rows;select migration.run('vehicles') as vehicle_rows;select migration.run('drivers') as driver_rows;select table_name, (new_data ->> 'rows')::int as rows from public.audit_logwhere action = 'migrated' and record_id = (select max(id) from migration.runs)::text and new_data ->> 'step' = 'drivers' order by id;SQL3 · The counts, the reconcile, and the end of the run
Section titled “3 · The counts, the reconcile, and the end of the run”docker exec -i supabase_db_opleet psql -qX -U postgres -d postgres -v ON_ERROR_STOP=1 <<'SQL'select v1_table, reason, count(*) as rows from migration.unmatchedwhere run_id = (select max(id) from migration.runs) and step = 'drivers' group by 1, 2 order by 1, 3 desc;select stage, count(*) as drivers from public.drivers where legacy_id is not null group by 1 order by 2 desc;select kind, status, count(*) as checks from public.background_checks group by 1, 2 order by 1, 2;select status, count(*) as tickets, count(driver_id) as with_driver, count(*) filter (where phone = '628000000000') as placeholder_phone from public.queue_tickets group by 1 order by 2 desc;select check_name, count(*) as lines from migration.reconcile() group by 1 order by 1;select migration.finish_run('succeeded');SQL4 · The reconcile's lines, on your Mac only
Section titled “4 · The reconcile's lines, on your Mac only”mkdir -p ../opleet-privatedocker exec supabase_db_opleet psql -qX -U postgres -d postgres -c "select * from migration.reconcile() where check_name like 'driver%'" > ../opleet-private/reconcile-be-dp-32.txtdocker exec supabase_db_opleet psql -qX -U postgres -d postgres -c "select v1_table, v1_key, reason from migration.unmatched where run_id = (select max(id) from migration.runs) and step = 'drivers' order by 1, 3, 2" >> ../opleet-private/reconcile-be-dp-32.txtwc -l ../opleet-private/reconcile-be-dp-32.txtExpect
Section titled “Expect”- Block 1:
tables_copied35 or so, then no unmapped line. If one is listed, stop: post it on #281. It names a field and a v1 value: a status or a source, never a person. - Block 2:
master_rowsandvehicle_rows0 if BE-DP-26 already ran since the reset, or their counts if not. Thendriver_rowsnear 3,407 drivers, plus their SIMs, about 2,974 checks and about 1,658 tickets. The drivers step's lines aredrivers,driver_documents,background_checksandqueue_tickets. - Block 3:
- Unmatched:
leads: the 5 deleted in v1 (zuki: they stay out), and the leads whose phone isn't in v2's form (11 on 2026-10-27, fewer once fixed in v1);bc: those leads' checks.
- Stages:
blacklistedabout 609 (Blacklist 299, plus D73's 310),listedabout 1,500, and so on. Noavailable: a driver in good standing with no car isapproved(D79).inactivefew or none, since D78 makes the re-approvedapproved. - Checks: the kinds and statuses of BE-DP-30's table 2.
- Tickets: about 1,658, with a driver on about 1,173.
placeholder_phonecounts the past tickets loaded with the placeholder phone (zuki, #281). - Reconcile:
drivers loadedanddriver blacklistsabsent.driver NIKsabsent, now that v1's NIKs are fixed.driver repossessed awaylists the repossessed drivers on Cuti or Suspend with an Approve row (D78, 5 on the copy), for your review before cutover. Lines from other checks belong to their steps.
- Unmatched:
- Block 4: a line count.
Post blocks 1 to 3 on #281, as printed. Don't post block 4's file. If a line in it needs your signature or a fix in v1, say which check or reason and how many.
If it fails
Section titled “If it fails”- Block 1,
tables_copied0:v1_liveisn't linked. Run BE-DP-07, then block 1 again. - Block 2,
migration.unmapped_values: block 1 listed a value. See above. - Block 2,
migration.step_drivers: … exactly one: the organization has more than one pool, and v1's drivers have none. Post the line on #281. - Block 2, a constraint name such as
drivers_nik_uniqueorqueue_tickets_number_unique: post the line on #281. It names the constraint, and the Backend Engineer fixes the step. - Anything else: post the
ERRORline on #281.
pnpm supabase db reset removes everything the night loaded, and BE-DP-07 links v1_live again. Nothing here touches staging or production.
Log each run as a comment on #281: date · who · result, with blocks 1 to 3.