21 lines
1.1 KiB
SQL
21 lines
1.1 KiB
SQL
-- AI-Einstellung je Haushalt (Arbeitspaket 4c): Adresse eines OpenAI-kompatiblen
|
|
-- Endpunkts (LiteLLM auf der Box), Modellnamen für Text und Bild, Schlüssel
|
|
-- verschlüsselt (lib/vault.ts, tresor.key unter /app/data). Kein Vorgabewert:
|
|
-- Jede geratene Adresse ist auf einer anderen Box falsch.
|
|
|
|
create table household_ai (
|
|
household_id uuid primary key references households (id) on delete cascade,
|
|
endpoint text not null check (endpoint ~ '^https?://' and length(endpoint) <= 500),
|
|
text_model text check (length(text_model) between 1 and 200),
|
|
vision_model text check (length(vision_model) between 1 and 200),
|
|
api_key_enc bytea,
|
|
updated_by uuid,
|
|
updated_at timestamptz not null default now(),
|
|
foreign key (updated_by, household_id) references members (id, household_id) on delete set null (updated_by)
|
|
);
|
|
|
|
alter table household_ai enable row level security;
|
|
alter table household_ai force row level security;
|
|
create policy household_ai_household on household_ai
|
|
using (household_id = app_household_id()) with check (household_id = app_household_id());
|