Skip to content

BE-DP-07 · Local v2 reads the copy through v1_live

ID BE-DP-07 · Level L0 · Pack Pack R1 · The v1 copy · Run order row 1, after BE-DP-06, and again after every pnpm supabase db reset · Issue #184

Your local v2 database reads every v1 table, and v1's view v_rental_fee_audit, through foreign tables in the schema v1_live, the way staging will read v1 itself (D36). Every later data-phase pack reads v1 from there: the money study (row 2), the machinery's snapshot and tests (row 4) and the domain steps (row 5). The row counts through v1_live match the copy's own.

v1_live is in your local database only. It isn't in any migration, so pnpm supabase db reset removes it: run this step again after each reset. The Data API doesn't expose it, and nobody but postgres may use it.

  • BE-DP-06 is done: docker ps --filter name=v1copy lists the container as Up.
  • The local stack is running, and you are at the root of your clone.

A no-op when it is already there. It reconnects the copy after pnpm supabase stop and start made the network again.

Terminal window
docker network connect supabase_network_opleet v1copy 2>/dev/null || true
Terminal window
docker exec -i supabase_db_opleet psql -U postgres -d postgres -v ON_ERROR_STOP=1 < tools/migration/v1-copy/link-v1copy.sql

3 · Rows per table, in the copy and through v1_live

Section titled “3 · Rows per table, in the copy and through v1_live”
Terminal window
docker exec -i v1copy psql -U postgres -d postgres -At -F ' ' -v schema=public < tools/migration/v1-copy/counts.sql > ../opleet-private/counts-copy.txt
docker exec -i supabase_db_opleet psql -U postgres -d postgres -At -F ' ' -v schema=v1_live < tools/migration/v1-copy/counts.sql > ../opleet-private/counts-v1_live.txt
head -1 ../opleet-private/counts-copy.txt ../opleet-private/counts-v1_live.txt
diff ../opleet-private/counts-copy.txt ../opleet-private/counts-v1_live.txt && echo "the same, table by table"
  • Block 1 prints nothing.
  • Block 2: CREATE EXTENSION, NOTICE lines saying the server and the schema don't exist yet (the first time only), CREATE SERVER, CREATE USER MAPPING, CREATE SCHEMA, REVOKE, IMPORT FOREIGN SCHEMA, then foreign_tables with the number of views from BE-DP-06 (the tables and v_rental_fee_audit, 35 on the copy of 2026-10-28).
  • Block 3: two (total: N tables) M lines with the same N and M, then the same, table by table. The counts stay in ../opleet-private; they are counts, but keep them with the dump.
Terminal window
docker exec supabase_db_opleet psql -U postgres -d postgres -At -c "select has_schema_privilege('anon', 'v1_live', 'usage'), has_schema_privilege('authenticated', 'v1_live', 'usage')"

f|f: the app's roles can't reach v1's data.

  • Block 2: could not translate host name "v1copy": the copy isn't on the network. Run block 1, then check docker ps --filter name=v1copy shows it Up (docker start v1copy if not), then block 2 again.
  • Block 2: password is required or permission denied for foreign-data wrapper postgres_fdw: the stack's postgres role can't use the wrapper the way this step assumes. Stop and post the line on #184; BE changes the step.
  • Block 2: type "…" does not exist: a v1 column type export.sql kept. Post the line; the fix goes into export.sql.
  • Block 3 prints differences: post the diff lines' table names and both counts on #184, which are counts only.
Terminal window
docker exec supabase_db_opleet psql -U postgres -d postgres -c "drop schema if exists v1_live cascade; drop server if exists v1 cascade"

Or pnpm supabase db reset, which removes it too. The copy itself is untouched.

Log each run as a comment on #184: the date, block 2's foreign_tables and block 3's two total lines.