Skip to content

BE-DP-11 · The money study, first: how v1 stores its money

ID BE-DP-11 · Level L0 · Pack Pack R2 · The money study · Run order row 2, first · Issue #185

The shape of v1's money is on #185, so the study's queries can be written against it. v1 keeps most of it inside jsonb (bills.data, debts.data), and its layout isn't written down anywhere. D34 makes the instalments inside bills the balance of record, so the study must first find where they are, what they're called and what they hold.

tools/migration/v1-copy/money-shapes.sql prints, for bills, debts, payments, onboarding, contracts and claim_letters:

  • their columns: type and how many rows fill each;
  • every path inside their jsonb columns, four levels down (such as data.cicilan[].nominal), with its JSON type, how many rows have it, and the form of its strings (date, timestamp, number, text, empty) and their length;
  • the values of enum-like keys only (status, type, method, bank and similar names), when there are at most 15.

It prints no name, phone, plate or one person's amount (D15). It reads the copy and changes nothing in it.

  • Pack R1 is done: the copy runs as v1copy (BE-DP-06), and docker ps --filter name=v1copy lists it as Up.
  • You are at the root of your clone, on main once this step's pull request is merged.
Terminal window
docker exec -i v1copy psql -qX -U postgres -d postgres < tools/migration/v1-copy/money-shapes.sql

Three sections, in a minute or two:

  • 1 · Columns: one row per column of the six tables, with filled and rows.
  • 2 · Paths: one row per path and JSON type. Several hundred rows is normal: bills.data alone may have dozens of keys.
  • 3 · Values: enum-like keys such as data.status, with their values (lunas, belum…) and counts.

Read section 3's value column before posting. It only lists keys whose names say status, type, method, bank and the like, with at most 15 values each. If one still shows a person's name or a number from a document, delete that row and say you did.

Then post all three sections on #185. If the output is too long for one comment, post each section as its own comment.

  • ERROR: post the line. It names a table, a column or a path, never a value.
  • It runs for more than ten minutes: let it finish. If it seems stuck, docker exec v1copy psql -U postgres -c "select now() - query_start, left(query, 60) from pg_stat_activity where state = 'active'" shows how long it has run. Those 60 characters are the script's own text, not data.

Nothing to undo: it reads only, and its tables are temporary.

Log each run as a comment on #185: the date and the three sections.