pgapi-multi-tenant-composite-keys
IN premise
All PgApi tables use composite primary keys `(id, project_id)` for multi-tenancy, with JSONB columns (not TEXT) for antecedents, outlist, and metadata
Summary
Every table in the PgApi storage layer identifies rows by a combination of the record's own ID and a project ID, which keeps different tenants' data isolated at the database level. The structured columns like antecedents and metadata are stored as JSONB rather than plain text, meaning Postgres can natively query and index their contents without requiring serialization or deserialization in application code.
Dependents
These beliefs depend on this one:
- pgapi-is-sql-native-multi-tenant — PgApi operates as a SQL-native multi-tenant implementation: all operations execute directly against PostgreSQL with no in-memory Network object constructed, composite primary keys on all tables provide project-level isolation, and each public method is a single committed transaction.
Details
| Source | entries/2026/04/28/reasons_lib-pg.md |