Skip to content

BE-DP-21 · How v1's tables join, and the shape of v1's logins, for the domain steps

ID BE-DP-21 · Level L0 · Pack Row 5 · The domain steps, first v1's shapes · Run order row 5, with BE-DP-20, before row 5's steps are written · Issue #278 to #281

The two things BE-DP-20 doesn't print, so the Backend Engineer can write row 5's loads from one round of output, without asking for another run:

  1. How v1's tables join, on the copy: every column and top-level jsonb key that reads like a key (a lead id, a plate, a unit id, a NIK, a user id, a bill id), whether it's unique in its table, and for each other key of the same kind, how many of its values that key has. That says which key leads from a lead to its onboarding, checks, queue tickets and bills, and from a car to its status rows.
  2. The shape of v1's logins, through v2_reader (TL-DP-02): how many, the form of their password hashes, every metadata key, and the values of role and permission-list keys. The access step (#278) reads these live, so the copy doesn't have them, and BE-DP-20 leaves them out.

Both print names of tables and keys, counts, hash forms and code-like values only: never an email, a name, a phone, a plate, a NIK or a hash (D15). Both only read.

  • BE-DP-20 has run, or runs in the same sitting. Its three files are in ../opleet-private.
  • docker ps --filter name=v1copy lists the copy as Up, and you are at the root of your clone, on main once this step's pull request is merged, or on its branch be/row5-joins-logins before that.
  • The password manager entry "Opleet v1 · v2_reader", for block 2.

A few minutes: it reads every key of every table once (not activity_log or the backups).

Terminal window
docker exec -i v1copy psql -qX -U postgres -d postgres < tools/migration/v1-copy/joins.sql > ../opleet-private/joins.txt
cat ../opleet-private/joins.txt

One password prompt: paste <V1_READONLY_PASSWORD>.

Terminal window
docker run --rm -it -v "$PWD/tools/migration/v1-copy:/sql:ro" postgres:17 psql "host=<V1_POOLER_HOST> port=5432 dbname=postgres user=v2_reader.<V1_PROJECT_REF> sslmode=require" -qX -P pager=off -f /sql/logins.sql | tee ../opleet-private/logins.txt

Block 1, three sections:

  • 1 · Keys, by family: one line per key, with rows, filled, distinct_values and unique_in_table (unique, or how many values repeat). Expect leads.data ->> lid unique, onboarding.data ->> lid and bc.data ->> lid among the lead keys, and vehicle_master.data ->> plat among the plates.
  • 1b · A table's id against its data.id: for the tables whose jsonb has an id, whether it equals the row's own id (equal = ids when it does).
  • 2 · Within a family: one line per pair of keys that share at least one value, with matched and of_values. A hundred or two lines is normal.

Block 2, four sections:

  • 1 · Logins: one line of counts; the aud and role table; hash_form, most likely $2a$10$… for every login (bcrypt, which Supabase's Auth reads as it is: R-ACC-58).
  • 2 · Metadata keys: each key of raw_app_meta_data and raw_user_meta_data with its type and count.
  • 3 · Code-like values: the values of role, the items of list keys such as an allowed list, and similar, with counts. Then a short table of keys whose values weren't listed and why.
  • 4 · Identities by provider: most likely email only.

Before posting, read block 1's key column and block 2's section 3 value column. They should hold only key names, role names, permission names and similar codes. If any cell is a person's name, an email, a plate or a number from a document, delete that line and say you did.

Post both outputs on the issues that need them:

  • Block 1: on #281 (drivers) and #280 (vehicles), the whole file on each.
  • Block 2: on #278 (access).
  • Block 1 runs for more than ten minutes: let it finish. If it is stuck, docker exec v1copy psql -U postgres -c "select now() - query_start, left(query, 80) from pg_stat_activity where state = 'active'" shows which table; post that table's name on #281.
  • Block 1 ERROR: post the line. It names a table or key, never a value.
  • Block 2 permission denied for schema v2_export: TL-DP-02 hasn't been applied on v1, or was undone. Post the line on #225.
  • Block 2 stops partway through section 3 (no role lines, and logins.txt ends where the screen did): psql showed that section through a pager and quitting it dropped the rest. The command now turns the pager off; run block 2 again and post section 3 in full.
  • Block 2 relation "v2_export.auth_identities" does not exist: post the line on #278; sections 1 to 3 have already printed and are enough to post.

Nothing to undo: both scripts only read, and block 1's tables are temporary. ../opleet-private/joins.txt and logins.txt stay with the dump.

Log each run as a comment on the issue it posts to: date · who · result · notes.