Data Model
Data Model
Section titled “Data Model”Last updated: 2026-05-19
Full schema lives in finstack-rs/migrations/. Below are tables added or modified during active development; historical tables are in earlier migrations (0001–0027).
database_provisions (migration 0028)
Section titled “database_provisions (migration 0028)”Tracks tenants that have provisioned a managed Postgres database via Post AI.
| Column | Type | Notes |
|---|---|---|
id | UUID PK | gen_random_uuid() |
tenant_id | UUID NOT NULL | FK → tenants(id) ON DELETE CASCADE; UNIQUE |
post_ai_tenant_id | TEXT NOT NULL | String representation of tenant_id UUID used as x-tenant-id with Post AI |
provisioned_at | TIMESTAMPTZ NOT NULL | now() default |
status | TEXT NOT NULL | 'active' default |
Constraints: UNIQUE (tenant_id) — ON CONFLICT DO NOTHING makes record_provision idempotent.
RLS: ENABLE ROW LEVEL SECURITY + FORCE ROW LEVEL SECURITY. Policy: tenant_id = current_setting('app.tenant_id', true)::uuid.
Index: database_provisions_tenant_id_idx on (tenant_id).