Repository navigation
Description
Found when #732 opened GET /v1/work-logs/public-feed to anonymous callers and production answered permission denied for table construction_projects. The 401 it used to return had been hiding the gap — the request never reached the query.
A sweep of production for the #481 shape:
select c.relname from pg_class c
where c.relkind = 'r'
and c.relnamespace::regnamespace::text = 'core'
and not has_table_privilege('service_role', c.oid, 'SELECT');29 tables. Migration 352 covers eight of them, #749 covers construction_projects because it was actively breaking a public page. These twenty remain:
application_assignment_history archived_external_jobs
archived_notifications background_check_events
background_check_providers generic_invitations
hris_connections hris_employee_mappings
hris_sync_logs inquiry_audit_log
invitation_rules job_match_scores
job_occupation_mappings message_templates
review_pins stripe_settings
success_fee_jobs system_config
user_relationships vanity_url_analytics
Why these are worth doing together rather than one incident at a time
This is the fourth time the same defect has been fixed individually — migrations 332, 335, 347, 352, and now 749. Each was found by an endpoint 500ing in an environment somebody happened to exercise. service_role is the server's own identity and bypasses RLS by design; every other table in core grants it. These are the anomaly, not the grant.
Local and production have drifted, which is what makes this untestable locally: core.construction_projects carries the grant locally and not in production, so the bug was invisible until a request reached production.
Acceptance
- A migration granting
service_roleon the twenty, written idempotently and scoped to a fixed list rather than "every table in core", so a future table has to be considered rather than swept in - Applied to dev, preview and prod, with the ledger recorded
- A check that fails when a
coretable exists thatservice_rolecannot read — the same shrink-only shape as the schema-reference guard in test(api): fail when a route reads a table that does not exist #651. Without it this recurs, because nothing today notices until an endpoint 500s - Confirm the drift itself: why local has grants production lacks. If a migration was applied locally but never remotely, the ledger should have caught that and did not
Related: #481 (the original eight), #749 (construction_projects), #732 (how it surfaced).
Activity
fix(db): grant the roles six core policies already name (#755) (#758)
fix(db): grant service_role the twenty core tables it cannot read, an…