BE-M0-35 · Sessions end on an access change (D37)
ID BE-M0-35 · Level L0 · Pack Pack G1 · The review's schema changes · Run order row 22b · Issue #150
A change to a person's roles or overrides, their own included, ends every session they have in auth.sessions and stamps profiles.access_changed_at (R-ACC-08). public.session_is_current() says whether the caller's login token was issued after that stamp, for proxy.ts to call on every request (R-ACC-48, its apps/web half in FE pack B2, #151). Permissions are still read from the tables on every query, never from the token (R-ACC-49).
This step changes no file: the code arrived with pack G1's pull request. It proves the change on your Mac's local stack.
Before
Section titled “Before”- BE-M0-34 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.
1 · Main, rebuilt from nothing
Section titled “1 · Main, rebuilt from nothing”The migration files were edited in place (D11), so the local database is rebuilt, never migrated.
git switch main && git pullpnpm supabase db reset2 · This part's tests
Section titled “2 · This part's tests”pnpm supabase test db supabase/tests/database/13_tenancy_access.test.sqlExpect
Section titled “Expect”- Block 1: "Finished supabase db reset".
- Block 2:
okon every line, including the four lines that startR-ACC-08orR-ACC-48, thenFiles=1, Tests=59andResult: PASS.
pnpm supabase db query --local "select proname, prosecdef from pg_proc where proname in ('session_is_current', 'end_sessions_on_access_change') order by 1"Two rows, both t: each runs as its owner, which is what lets the trigger delete from auth.sessions.
If it fails
Section titled “If it fails”supabase db resetstops on a migration: paste the file name and the error into #150. Don't edit the file.- A test fails: paste the
not okline 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.