L10b Betrieb & Aufräumen: Migrationen clientId je Mandant und KI-Token-Kontingent
- 20260915090000_betrieb_client_id_per_tenant (Aufräumpunkt f, L8 offener Punkt 6): globale Unique-Indizes auf client_id (material_usages, work_sessions, time_entries, activity_notes, photos, voice_notes, reports, signatures) → @@unique([tenantId, clientId]). Offline-IDs sind nur je Mandant eindeutig; ein Replay derselben ID in einem anderen Mandanten scheiterte bisher mit internem Fehler. Keine neuen Tabellen. - 20260915091000_betrieb_ai_token_limit (Aufräumpunkt k): tenant_settings.ai_monthly_token_limit (NULL = Plattform-Vorgabe AI_MONTHLY_TOKEN_LIMIT, 0 = unbegrenzt). Keine neue Tabelle. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
-- L10b Betrieb & Aufräumen (Aufräumpunkt f, L8 offener Punkt 6):
|
||||
-- Offline client ids are generated per device and only need to be unique within a tenant.
|
||||
-- A global unique index let a replay with the same client id in another tenant fail with an
|
||||
-- internal error (and leaked the existence of the id across tenants). Tables already carry
|
||||
-- tenant RLS; no new tables.
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "activity_notes_client_id_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "material_usages_client_id_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "photos_client_id_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "reports_client_id_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "signatures_client_id_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "time_entries_client_id_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "voice_notes_client_id_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "work_sessions_client_id_key";
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "activity_notes_tenant_id_client_id_key" ON "activity_notes"("tenant_id", "client_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "material_usages_tenant_id_client_id_key" ON "material_usages"("tenant_id", "client_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "photos_tenant_id_client_id_key" ON "photos"("tenant_id", "client_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "reports_tenant_id_client_id_key" ON "reports"("tenant_id", "client_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "signatures_tenant_id_client_id_key" ON "signatures"("tenant_id", "client_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "time_entries_tenant_id_client_id_key" ON "time_entries"("tenant_id", "client_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "voice_notes_tenant_id_client_id_key" ON "voice_notes"("tenant_id", "client_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "work_sessions_tenant_id_client_id_key" ON "work_sessions"("tenant_id", "client_id");
|
||||
@@ -0,0 +1,7 @@
|
||||
-- L10b Betrieb & Aufräumen (Aufräumpunkt k, Spec §31 Kostenlimit):
|
||||
-- Optional monthly AI token budget (input + output tokens of AiGeneration) per tenant.
|
||||
-- NULL = platform default from env AI_MONTHLY_TOKEN_LIMIT, 0 = unlimited.
|
||||
-- tenant_settings is already tenant-bound (RLS, TENANT_MODELS) — no new table.
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "tenant_settings" ADD COLUMN "ai_monthly_token_limit" INTEGER;
|
||||
Reference in New Issue
Block a user