Skip to content

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.

  • You are at the root of your clone, on the drivers step's branch (be/281-drivers-step), after git pull, pnpm supabase db reset and BE-DP-07. The reset removes v1_live, so you link it again.
  • docker ps --filter name=v1copy lists the copy as Up.

1 · A run, its snapshot, and what's unmapped

Section titled “1 · A run, its snapshot, and what's unmapped”
Terminal window
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;
SQL
Terminal window
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_log
where action = 'migrated' and record_id = (select max(id) from migration.runs)::text
and new_data ->> 'step' = 'drivers' order by id;
SQL

3 · The counts, the reconcile, and the end of the run

Section titled “3 · The counts, the reconcile, and the end of the run”
Terminal window
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.unmatched
where 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');
SQL

4 · The reconcile's lines, on your Mac only

Section titled “4 · The reconcile's lines, on your Mac only”
Terminal window
mkdir -p ../opleet-private
docker 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.txt
docker 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.txt
wc -l ../opleet-private/reconcile-be-dp-32.txt
  • Block 1: tables_copied 35 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_rows and vehicle_rows 0 if BE-DP-26 already ran since the reset, or their counts if not. Then driver_rows near 3,407 drivers, plus their SIMs, about 2,974 checks and about 1,658 tickets. The drivers step's lines are drivers, driver_documents, background_checks and queue_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: blacklisted about 609 (Blacklist 299, plus D73's 310), listed about 1,500, and so on. No available: a driver in good standing with no car is approved (D79). inactive few or none, since D78 makes the re-approved approved.
    • Checks: the kinds and statuses of BE-DP-30's table 2.
    • Tickets: about 1,658, with a driver on about 1,173. placeholder_phone counts the past tickets loaded with the placeholder phone (zuki, #281).
    • Reconcile: drivers loaded and driver blacklists absent. driver NIKs absent, now that v1's NIKs are fixed. driver repossessed away lists 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.
  • 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.

  • Block 1, tables_copied 0: v1_live isn'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_unique or queue_tickets_number_unique: post the line on #281. It names the constraint, and the Backend Engineer fixes the step.
  • Anything else: post the ERROR line 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.