BetterFrame/server/src/shared/db
Mitchell R 66653af360
feat: implement multi-tenant support with PG schema isolation
Adds tenant management for PostgreSQL deployments. Each tenant gets its
own PG schema (tenant_<slug>) with a full set of BetterFrame tables.
SQLite deployments stay single-tenant with no behavior change.

Key changes:
- Run PUBLIC_MIGRATIONS (tenants + global_admins tables) during PG init
- Auto-create "default" tenant (schema=public) on first boot
- createTenantSchema() runs TENANT_MIGRATIONS in a new PG schema
- DbAdapter.setSearchPath() for per-request schema switching (PG)
- Tenant CRUD in Repository (listTenants, create, update, delete)
- Middleware resolves bf_tenant cookie and sets search_path per request
- Admin UI: /admin/tenants with CRUD + tenant switching via cookie
- Tenant dropdown in topbar (Layout) when >1 tenant exists
- Tenant nav item in sidebar

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-26 07:22:01 +02:00
..
config.ts fix(db): clean config field names under db: object 2026-05-24 05:12:53 +02:00
db-adapter.ts feat: implement multi-tenant support with PG schema isolation 2026-05-26 07:22:01 +02:00
init.ts feat: implement multi-tenant support with PG schema isolation 2026-05-26 07:22:01 +02:00
mappers.ts feat: implement multi-tenant support with PG schema isolation 2026-05-26 07:22:01 +02:00
migrations-pg.ts refactor: migrate all auto-increment PKs to UUIDv7 text IDs 2026-05-26 07:11:45 +02:00
migrations.ts refactor(streams): store RTSP components separately for ONVIF cameras 2026-05-26 06:51:33 +02:00
pg-adapter.ts feat: implement multi-tenant support with PG schema isolation 2026-05-26 07:22:01 +02:00
repository.ts feat: implement multi-tenant support with PG schema isolation 2026-05-26 07:22:01 +02:00
sqlite-adapter.ts feat: implement multi-tenant support with PG schema isolation 2026-05-26 07:22:01 +02:00
util.ts fix(db): handle PG JSONB as native objects in j() mapper 2026-05-26 01:58:06 +02:00