feat(rls): Phase 1 #3 — CompanyMission RLS + callsite fixes#131
Merged
Conversation
- Migration 20260528000000: enable RLS + FORCE on CompanyMission, composite index on (organizationId, id), SELECT/INSERT/UPDATE/DELETE policies for app_user, grants to app_user + admin_user - Wrap prisma.companyMission.findUnique in GET /api/mission with withOrgContext - Wrap prisma.companyMission.upsert in POST/PUT /api/mission with withOrgContext - Wrap getMissionForOrg() in goal-context.ts with withOrgContext (explicit orgId required — called from BullMQ/heartbeat workers where ALS is empty) RLS_ENFORCEMENT_ENABLED=false; wrapping is a no-op until flag flip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
20260528000000_rls_phase1_companymission: enables RLS + FORCE onCompanyMission, adds composite index on(organizationId, id), SELECT/INSERT/UPDATE/DELETE policies forapp_user, grants toapp_user+admin_userprisma.companyMission.findUniqueinGET /api/missionwithwithOrgContextprisma.companyMission.upsertinPOST/PUT /api/missionwithwithOrgContextgetMissionForOrg()insrc/lib/goals/goal-context.tswithwithOrgContext(explicitorganizationIdrequired — function is called from BullMQ/heartbeat workers where ALS is empty;withTenant()would break there)RLS_ENFORCEMENT_ENABLED=false— allwithOrgContextwrapping is a no-op until the flag is flipped after all 14 migrations land.Callsite audit
Grep verified: exactly 3 callsites for
companyMission.outside generated code. No workers or crons callprisma.companyMissiondirectly.Test plan
pnpm precheck— TS ✅ vitest ✅ ESLint ✅ (4119 tests, 307 files)SELECT COUNT(*) FROM "CompanyMission"asapp_userwithoutapp.current_org_idset — must return 0 rowsapp.current_org_idto a valid org ID — must return that org's mission onlyGET /api/mission?orgId=<id>andPOST /api/missionstill work with flag off🤖 Generated with Claude Code