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.
Before
Section titled “Before”- BE-DP-06 is done:
docker ps --filter name=v1copylists the container as Up. - The local stack is running, and you are at the root of your clone.
1 · The copy on the stack's network
Section titled “1 · The copy on the stack's network”A no-op when it is already there. It reconnects the copy after pnpm supabase stop and start made the network again.
docker network connect supabase_network_opleet v1copy 2>/dev/null || true2 · The link
Section titled “2 · The link”docker exec -i supabase_db_opleet psql -U postgres -d postgres -v ON_ERROR_STOP=1 < tools/migration/v1-copy/link-v1copy.sql3 · Rows per table, in the copy and through v1_live
Section titled “3 · Rows per table, in the copy and through v1_live”docker exec -i v1copy psql -U postgres -d postgres -At -F ' ' -v schema=public < tools/migration/v1-copy/counts.sql > ../opleet-private/counts-copy.txtdocker 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.txthead -1 ../opleet-private/counts-copy.txt ../opleet-private/counts-v1_live.txtdiff ../opleet-private/counts-copy.txt ../opleet-private/counts-v1_live.txt && echo "the same, table by table"Expect
Section titled “Expect”- Block 1 prints nothing.
- Block 2:
CREATE EXTENSION,NOTICElines 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, thenforeign_tableswith the number of views from BE-DP-06 (the tables andv_rental_fee_audit, 35 on the copy of 2026-10-28). - Block 3: two
(total: N tables) Mlines with the same N and M, thenthe same, table by table. The counts stay in../opleet-private; they are counts, but keep them with the dump.
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.
If it fails
Section titled “If it fails”- Block 2:
could not translate host name "v1copy": the copy isn't on the network. Run block 1, then checkdocker ps --filter name=v1copyshows it Up (docker start v1copyif not), then block 2 again. - Block 2:
password is requiredorpermission denied for foreign-data wrapper postgres_fdw: the stack'spostgresrole 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 typeexport.sqlkept. Post the line; the fix goes intoexport.sql. - Block 3 prints differences: post the
difflines' table names and both counts on #184, which are counts only.
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.