Skip to content

BE-M0-38 · Audit source and transaction id; checkpoints by week

ID BE-M0-38 · Level L0 · Pack Pack G1 · The review's schema changes · Run order row 22b · Issue #150

A change made directly in the database is logged with source system and the database user's name; one through the API reads app, and a job still marks cron (R-AUD-05). Audit rows written in one transaction share its id (R-AUD-13). checkpoint_interval_weeks replaces checkpoint_interval_days: v_checkpoint_due gives each rented car its due week, Monday to Friday in the pool's date, and is_overdue from the Monday after (R-INSP-06, R-INSP-10). v1's interval in days converts by rounding up to whole weeks in the data phase.

This step changes no file: the code arrived with pack G1's pull request. It proves the change on your Mac's local stack.

  • BE-M0-37 is Done, or you run this step on its own after the same block 1.
  • You are in ~/opleet-v2/opleet on main and the local stack is running.

The migration files were edited in place (D11), so the local database is rebuilt, never migrated.

Terminal window
git switch main && git pull
pnpm supabase db reset
Terminal window
pnpm supabase test db supabase/tests/database/20_views_audit.test.sql
  • Block 1: "Finished supabase db reset".
  • Block 2: ok on every line, then Files=1, Tests=23 and Result: PASS.
Terminal window
pnpm supabase db query --local "update public.legal_entities set address = address where code = 'E2E'; select source, db_user from public.audit_log order by id desc limit 1"

system and postgres: your own change through the CLI is a direct change.

  • supabase db reset stops on a migration: paste the file name and the error into #150. Don't edit the file.
  • A test fails: paste the not ok line and the lines under it that start with #. The test's description starts with the rule it proves.
  • "permission denied" or "must be owner" on auth.sessions: stop and paste it. That means a migration can't end sessions on this stack (D37); BE says so on the issue before changing anything.

Nothing to undo: the step changes no file. pnpm supabase db reset rebuilds the local database from main at any time. Never run any part of it against staging or production.

Log each run as a comment on #150: the date, the last lines of block 2, and the check's output.