- users + tenant_memberships tables (tenant-scoped)
- RLS policy on tenant_memberships using set_config('app.current_tenant_id', ...)
- withTenantContext() helper for transaction-scoped tenant context
- separate non-superuser app role (b2bcall_app): the default Docker postgres
user is SUPERUSER and always bypasses RLS even with FORCE, so the app must
never connect through the migration/owner role. Documented in
docs/TENANT_ISOLATION.md.
- automated isolation test proving tenant A never sees tenant B's data
25 lines
597 B
JSON
25 lines
597 B
JSON
{
|
|
"name": "@b2bcall/database",
|
|
"version": "0.0.1",
|
|
"private": true,
|
|
"main": "src/index.ts",
|
|
"types": "src/index.ts",
|
|
"scripts": {
|
|
"prisma:generate": "prisma generate",
|
|
"prisma:migrate": "prisma migrate dev",
|
|
"prisma:deploy": "prisma migrate deploy",
|
|
"typecheck": "tsc --noEmit",
|
|
"test:isolation": "tsx src/__tests__/tenant-isolation.test.ts"
|
|
},
|
|
"dependencies": {
|
|
"@prisma/adapter-pg": "^7.10.0",
|
|
"@prisma/client": "^7.10.0",
|
|
"pg": "^8.23.0"
|
|
},
|
|
"devDependencies": {
|
|
"@types/pg": "^8.23.1",
|
|
"prisma": "7.10.0",
|
|
"tsx": "^4.23.12"
|
|
}
|
|
}
|