Skip to content

feat(db): RLS on the communication batch (RLS unit 7) - #348

Merged
juancodedev merged 1 commit into
mainfrom
feat/rls-unit7
Nov 5, 2026
Merged

juancodedev merged 1 commit into
mainfrom
feat/rls-unit7

Conversation

@juancodedev

Copy link
Copy Markdown
Owner

Summary

This is the first business-table batch of tenant-isolation-rls unit 7. 0027_communication_rls.sql enables RLS and creates the tenant_isolation policy on message_log, whatsapp_templates and push_subscriptions. A test asserts that the file's statements are exactly the ones rls.ts generates for those tables. The drift baseline is regenerated to include 0027.

Readiness: a mapping pass found every runtime access to these tables inside withTenantTransaction, except the Meta WhatsApp webhook. WhatsApp is not in use; the migration header documents that the webhook now fails under the policy instead of reaching another tenant's row.

Rehearsal (Neon branch copied from production, connected as vyloop_app)

  • Templates, history, campaigns and deliveries: 200 for all 6 tenants. Each tenant's history total matches the count the owner role sees.
  • The customer push-subscription route returns 200, and each customer sees exactly their own subscriptions.
  • The subscription maintenance sweep runs with no errors.
  • db:rls --expect communication and db:drift pass.

Verification

  • scripts check-rls + drift tests: 126/126.
  • packages/db: 321/322. The one failure is environmental: it checks that the worktree directory name ends in vyloop.

Production apply: 0027 goes to production before this PR merges. An applied migration that is not yet on main does not block the drift gate.

Risk: item 1 (which rows production queries see) and item 2 (tenant isolation).

🤖 Generated with Claude Code

@juancodedev
juancodedev merged commit fd57f6e into main Nov 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant