Repository navigation
fix(db): grant the seven tables migration 305 created - #558
Conversation
Migration 305 created seven tables with RLS enabled and zero GRANT statements. A missing GRANT fails before RLS is evaluated, so every access — including service_role — returns "permission denied for table ...". All seven have been unreachable since they were created: core.privacy_data_requests 403 core.privacy_opt_outs 403 core.eeo_self_identification 403 core.eeo_reports 403 core.hiring_projects 403 core.hiring_project_roles 403 core.hiring_project_crew 403 Verified live against the local database via PostgREST, alongside core.application_activity returning 200 as a control. Same class of bug as 332_api_keys_grants and 335_scheduling_grants — the third time it has shipped, which suggests the gap is in how migrations are reviewed rather than in any one migration. Found while starting #535 (wire the EEO report to real data). That work is blocked on this: the table holding the data cannot be read by anything. ## The deliberate asymmetry on EEO data 305's policy on eeo_self_identification is `auth.uid() = user_id` for SELECT and INSERT — an applicant may record and read their own protected-class data and nobody else's. That is the correct privacy posture and this migration does not widen it. Employers must never read individual rows; only aggregates computed server-side under service_role. authenticated gets SELECT + INSERT and no UPDATE or DELETE, because a voluntary self-identification is an audit record rather than an editable field. Not executed locally: the Docker CLI is unresponsive on this machine, so DDL cannot be run. The SQL mirrors 335 exactly, and the api-tests job starts Supabase and applies migrations, so CI executes it.
|
Correcting the PR description. I wrote that "the api-tests job starts Supabase and applies migrations, so CI executes it." That is wrong for this PR: So this migration is executed nowhere yet — not locally (the Docker CLI is hung on my machine), and not in CI. What I did instead was verify the problem in the deployed environments, read-only via the Management API: So the gap is real in prod and dev, not a local artefact — which is stronger evidence than the local 403s I started from. Merging this does not apply it; migrations go out separately via Worth noting separately: a migration-only PR gets no database CI at all. That is how three grant-gap migrations (305, and the ones 332/335 fixed) shipped unnoticed. Adding |
Found while starting #535. That work is blocked on this, so this is the first step rather than the whole ticket.
Seven tables have been unreachable since they were created
Migration 305 created them with RLS enabled and zero GRANT statements. A missing GRANT fails before RLS is evaluated, so every access — including
service_role— returnspermission denied for table ....Verified live via PostgREST, with
core.application_activityas a 200 control:Same class as
332_api_keys_grantsand335_scheduling_grants— the third time this has shipped, which points at how migrations get reviewed rather than at any one migration.The deliberate asymmetry on EEO data
305's policy on
eeo_self_identificationisauth.uid() = user_idfor SELECT and INSERT — an applicant may record and read their own protected-class data and nobody else's. That's the correct privacy posture and this migration does not widen it. Employers must never read individual rows; only aggregates computed server-side underservice_role.authenticatedgets SELECT + INSERT and deliberately no UPDATE/DELETE: a voluntary self-identification is an audit record, not an editable field.Not executed locally
The Docker CLI is unresponsive on this machine (
docker versionreturns nothing), so I couldn't run DDL. The SQL mirrors 335 exactly, and the api-tests job starts Supabase and applies migrations — so CI executes it. I'd rather say that than imply I ran it.Why #535 is bigger than filed
See the issue comment: beyond grants, nothing collects EEO data — no UI, no endpoint, only the generated types reference the table. Wiring the report to "real data" today would produce an all-zero report, which on a compliance screen reads as "no adverse impact" when it means "no data". That distinction needs a product decision.
🤖 Generated with Claude Code