BE-DP-26 · A night on the v1 copy with master data and vehicles
ID BE-DP-26 · Level L0 · Pack Row 5 · The domain steps · Run order row 5, after the pull request with BE-DP-25's answers is merged · Issue #280
A night on your local stack, against the real v1 copy, runs the first two domain steps and reconciles them:
- master_data: the organization, its pools and legal entities, and v1's lists (R-MD-17, R-MD-18);
- vehicles: one car per
vehicle_masterrow, or an unmatched row with its reason, and every plate a car has carried onto that car (R-VEH-28 to R-VEH-30).
The reconcile lists what still differs. Each line is fixed in v1, mapped in a pull request, or signed by you with its reason (D18, R-MIG-06).
legacy and the loaded rows are a copy of v1's data in your local database: personal data, as the dump is (D15). They are local only, and pnpm supabase db reset removes them. The counts below are safe to post. The reconcile's lines name unit ids, so they stay on your Mac.
Before
Section titled “Before”- BE-DP-25 is logged on #280, and the pull request with its answers is merged. That pull request holds the organization, pools, legal entities and value_map rows.
- You are at the root of your clone, on main, after
git pull,pnpm supabase db resetand BE-DP-07. The reset removesv1_live, so you link it again.
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-26, local, on the v1 copy') 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 two steps
Section titled “2 · The two 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 table_name, (new_data ->> 'rows')::int as rows from public.audit_logwhere action = 'migrated' and record_id = (select max(id) from migration.runs)::text order by id;SQL3 · The reconcile, counted, and the end of the run
Section titled “3 · The reconcile, counted, 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 reason, count(*) as cars from migration.unmatchedwhere run_id = (select max(id) from migration.runs) and step = 'vehicles' group by 1 order by 2 desc;select check_name, count(*) as lines from migration.reconcile() group by 1 order by 1;select status, supply_status, count(*) as cars from public.vehicles group by 1, 2 order by 1, 2;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()" > ../opleet-private/reconcile-be-dp-26.txtwc -l ../opleet-private/reconcile-be-dp-26.txtExpect
Section titled “Expect”- Block 1:
tables_copied35 or so, then no unmapped line. If one is listed, stop: the value has no row yet. Post the line on #280; it names a field and a v1 value, never a person. - Block 2:
master_rowsnear 100, andvehicle_rowsnear 1,750 plus the temporary plates. Then one line per table:organizations1, then the pools, the legal entities and v1's lists, about as BE-DP-25 counted them;charge_types1, which is Lain-lain (R-MD-17);- then
vehiclesandvehicle_plate_history(about 146 temporary plates).
- Block 3:
- the unmatched cars by reason, near BE-DP-25's table 4;
- the reconcile's lines by check;
- the cars by status, about as BE-DP-20 counted them, with
inactivenear the 105 Not Aktif cars; - then the run finishes.
- Block 4: a line count.
The checks should read like this:
vehicles loadedhas no line: every v1 car is a car or an unmatched row;vehicle plateshas no line, unless BE-DP-25 found a temporary plate on two cars;unmatched rowshas one line per unmatched car.
Post blocks 1 to 3 on #280, 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 and how many lines, and the Backend Engineer writes the signatures for your review.
If it fails
Section titled “If it fails”- Block 1,
relation "v1_live…" does not existortables_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.target is empty: the pull request with BE-DP-25's answers isn't on your main. Rungit pullandpnpm supabase db reset, then start again. - Block 2,
duplicate key value violates unique constraint: post the line on #280. It names the constraint, such asvehicles_vin_unique, and the Backend Engineer fixes the step. - Anything else: post the
ERRORline on #280.
pnpm supabase db reset removes the run, the snapshot and everything loaded. Delete ../opleet-private/reconcile-be-dp-26.txt when you're done with it. Nothing here touches staging, production or v1.
Log each run as a comment on #280: date · who · result, with blocks 1 to 3.