Skip to content

BE-DP-16 · Where v1 records a repossession, counted on the copy

ID BE-DP-16 · Level L0 · Pack Pack 0e · The repo request · Run order row 0e, any time after BE-DP-08; before the rentals step (row 5) is written · Issue #268

The counts are on #268 that the rentals step needs before it can open D71's migrated requests: which v1 onboarding rows record a repossession, and where v1 records it.

D71 opens one repo request for every v1 rental the rentals step maps to repossessing. BE-DP-08 found three onboarding statuses, Approve, Booked and Listed, and D69 maps them by status; none of them is a repossession. So no rule yet says which v1 rows become repossessing, and this step can't count a mapping that doesn't exist. It finds where v1 records a repossession instead, wherever it is, and counts what it finds there, for zuki and the CTO to decide the mapping on #268.

The script reads the copy and changes nothing in it. It prints table and column names, status values, counts and onboarding ids, never another value (D15).

  • BE-DP-08 is done.
  • docker ps --filter name=v1copy lists the copy as Up, and you are at the root of your clone, on main once pack 0e has merged, or on its branch be/268-repo-requests before that.
Terminal window
docker exec -i v1copy psql -U postgres -d postgres -v ON_ERROR_STOP=1 < tools/migration/v1-copy/repossessing.sql

CREATE TABLE twice, CREATE FUNCTION and DO, then two tables.

The first has block, source, value and rows:

  • Block 1: every status of v1's onboarding rows and how many rows have it. BE-DP-08 found Approve, Booked and Listed; a status beyond those is what to look at first.
  • Block 2: where v1 names a repossession: a table whose name reads like one (table <name>, value (rows)), or a column or jsonb key that does, with how many rows hold something in it, grouped by that row's status. "Reads like one" means repo as a word, not report or repository, or tarik, penarikan or sita.
  • Block 3: status values that read like one, in any status column or a jsonb status key, with their counts. A car status such as Repossess in vehicle_status counts here too.

The second has one row: onboarding_rows_found and onboarding_ids, the ids of the onboarding rows that blocks 2 and 3 found. They are v1's ids, for looking a row up in v1; nothing else about the driver.

(0 rows) in the first table's blocks 2 and 3 and 0 found means v1 names no repossession under those words: say so on #268, since then the rentals step maps none to repossessing and D71 opens no migrated request.

Post both tables on #268, as printed.

Table and column names, statuses, counts and ids only. If a value in blocks 2 or 3 reads like a person's name or a number from a document, leave that row out and say you did.

  • relation "onboarding" does not exist: the copy isn't BE-DP-06's. Check docker exec v1copy psql -U postgres -c '\dt public.*' and say on #268 what the rentals table is called.
  • It runs for more than ten minutes: let it finish; it reads every status and jsonb column once. 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.
  • Anything else: paste the error into #268.

Nothing to undo: the script writes only temporary tables, which go when it ends.

Log each run as a comment on #268: date · who · result · notes, with both tables.