Skip to content

BE-DP-13 · A first night on the v1 copy: a run, the snapshot and an empty reconcile

ID BE-DP-13 · Level L0 · Pack Pack R4 · The migration machinery · Run order row 4, after the pull request for #186 is merged · Issue #186

The machinery runs a night's frame on your local stack against the real v1 copy:

  • it begins a run;
  • it snapshots every v1 table from v1_live into legacy (R-MIG-01), table by table with the same counts as the copy;
  • it finds nothing unmapped and nothing to reconcile, because no domain step exists yet (R-MIG-02, R-MIG-05);
  • it finishes the run.

It's the machinery's first contact with v1's real shapes. The domain steps (row 5) build on it.

legacy holds a copy of v1's data in your local database: personal data, as the dump is (D15). It is local only, and pnpm supabase db reset removes it.

  • The pull request for #186 is merged, and BE-DP-12 is logged clean.
  • You are at the root of your clone, on main, after git pull, pnpm supabase db reset and BE-DP-07 (the reset removes v1_live, so link it again).
  • ../opleet-private/counts-copy.txt is there, from BE-DP-07.

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-13, local, on the v1 copy') as run;
select migration.snapshot() as tables_copied;
select count(*) as unmapped from migration.unmapped_values();
SQL

2 · The snapshot's counts against the copy's

Section titled “2 · The snapshot's counts against the copy's”
Terminal window
docker exec -i supabase_db_opleet psql -qX -At -F ' ' -U postgres -d postgres -c "select '(total: ' || count(*) || ' tables) ' || sum(rows) from migration.snapshot_tables where run_id = (select max(id) from migration.runs)"
head -1 ../opleet-private/counts-copy.txt

3 · The reconcile, and the end of the run

Section titled “3 · 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 count(*) as unexplained from migration.reconcile();
select migration.finish_run('succeeded');
select id, status, finished_at is not null as finished from migration.runs order by id desc limit 1;
SQL
  • Block 1: run 1, then a NOTICE that schema "legacy" does not exist (the first time only), tables_copied 35 (34 tables and the view v_rental_fee_audit, since #302), and unmapped 0.
  • Block 2: the same line twice, such as (total: 35 tables) a figure 877 rows above 164,076 on the copy of that day. The copy's figure is from when BE-DP-07 ran; the snapshot reads the copy, so they match.
  • Block 3: unexplained 0, then the run reads succeeded and finished.
Terminal window
docker exec supabase_db_opleet psql -U postgres -d postgres -At -c "select has_schema_privilege('authenticated', 'legacy', 'usage'), has_schema_privilege('authenticated', 'migration', 'usage')"

f|f: the app's users can't reach the snapshot or the machinery (R-MIG-08).

  • Block 1: relation "v1_live…" does not exist or tables_copied 0: v1_live isn't linked. Run BE-DP-07, then block 1 again.
  • Block 1: migration.no_open_run: the first line didn't run. Run block 1 again from the top.
  • Block 2's totals differ: post both lines on #186; they're counts only.
  • Anything else: post the ERROR line. It names a table or a function, never a row.

pnpm supabase db reset removes the run, the snapshot and legacy. Nothing here touches staging, production or v1.

Log each run as a comment on #186: the date, block 1's three numbers, block 2's two lines, and block 3's result.