ADR-0002: Enforce tenant isolation in PostgreSQL with Row-Level Security
- Status: proposed
- Date: 2026-11-05
Context
Section titled “Context”NotiFi is multi-tenant and stores sensitive visitor, contact and incident data. Application-level query scopes alone are insufficient protection against a missed filter or a future code path.
Decision
Section titled “Decision”NotiFi uses a shared PostgreSQL database with a tenant_id on tenant-owned
records and Row-Level Security (RLS) policies to enforce isolation.
Every request and background job establishes its tenant context in the database transaction before accessing tenant-owned tables. Cross-tenant administrative access uses a narrowly defined, audited path rather than bypassing RLS in normal application code.
Consequences
Section titled “Consequences”Tenant isolation is enforced close to the data and is testable independently of the web application. Migrations, background jobs, reporting and support tooling must all establish tenant context deliberately.