Qualify every table a policy names, and test that they are #5

Merged
paulhitt merged 1 commits from fix/qualify-tables-inside-policies into main 2026-09-03 11:19:37 +00:00
paulhitt commented 2026-09-03 11:19:26 +00:00 (Migrated from gitlab.com)

The files deployment failed on this: relation "clearance_revocations" does not exist. A policy body is parsed when the policy is CREATED, under
whatever search_path the migration runs with — and the migrator's does not
include the tenant schema. So SELECT 1 FROM clearance_revocations inside
a policy is a script that parses perfectly, passes every test this repository
had, and fails only against a real database.

Four references across 004 and 005, all now :schema.-qualified, which is the
convention 003 already followed.

⚠️ It failed AFTER creating the table, so t_default was left with
clearance_revocations present and the migration unrecorded. Both scripts use
CREATE TABLE IF NOT EXISTS and DROP POLICY IF EXISTS — the idempotence the
migrator's own documentation asks for — so re-running lands cleanly on that
state rather than needing it unpicked by hand.

The new test would have caught it: reintroducing the exact line fails with
the file and line number. It skips IS DISTINCT FROM and EXTRACT(x FROM y), which are not table references and which the first version of the check
reported as bugs.

accounts.flamenet.io is already on the new image and healthy; files is still
on the previous one because the migration gate stopped before it was
restarted, which is the gate working.

The files deployment failed on this: `relation "clearance_revocations" does not exist`. A policy body is parsed when the policy is CREATED, under whatever search_path the migration runs with — and the migrator's does not include the tenant schema. So `SELECT 1 FROM clearance_revocations` inside a policy is a script that parses perfectly, passes every test this repository had, and fails only against a real database. Four references across 004 and 005, all now :schema.-qualified, which is the convention 003 already followed. ⚠️ It failed AFTER creating the table, so t_default was left with clearance_revocations present and the migration unrecorded. Both scripts use CREATE TABLE IF NOT EXISTS and DROP POLICY IF EXISTS — the idempotence the migrator's own documentation asks for — so re-running lands cleanly on that state rather than needing it unpicked by hand. The new test would have caught it: reintroducing the exact line fails with the file and line number. It skips `IS DISTINCT FROM` and `EXTRACT(x FROM y)`, which are not table references and which the first version of the check reported as bugs. accounts.flamenet.io is already on the new image and healthy; files is still on the previous one because the migration gate stopped before it was restarted, which is the gate working.
paulhitt commented 2026-09-03 11:19:27 +00:00 (Migrated from gitlab.com)

assigned to @paulhitt

assigned to @paulhitt
paulhitt (Migrated from gitlab.com) merged commit a3393f1fe4 into main 2026-09-03 11:19:37 +00:00
paulhitt commented 2026-09-03 11:19:39 +00:00 (Migrated from gitlab.com)

mentioned in commit a3393f1fe4

mentioned in commit a3393f1fe4c52815d3368eefbbf605ac4c672234
This repo is archived. You cannot comment on pull requests.
No Reviewers
No labels
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: extant2000/flamenet-files#5