Files
msolarczekandClaude Opus 5 c8e6f30a27
CI / build-and-check (push) Canceled after 0s
CI / audit (push) Canceled after 0s
CI / sbom (push) Canceled after 0s
Basis: Certvia dev@a48c5fb als Fundament für Craftvia
Unveränderter Stand von certvia/dev (a48c5fb) plus Craftvia-Spezifikation
und Brandbook unter docs/craftvia/. ISMS-Module werden im Folgecommit entfernt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 11:05:39 +02:00

37 lines
1.1 KiB
SQL

-- CreateTable
CREATE TABLE "control_implementations" (
"id" TEXT NOT NULL,
"tenant_id" TEXT NOT NULL,
"req_id" TEXT NOT NULL,
"control" TEXT NOT NULL,
"status" TEXT NOT NULL DEFAULT 'offen',
"note" TEXT,
"updated_by_id" TEXT,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "control_implementations_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "control_implementations_tenant_id_idx" ON "control_implementations"("tenant_id");
-- CreateIndex
CREATE INDEX "control_implementations_tenant_id_control_idx" ON "control_implementations"("tenant_id", "control");
-- CreateIndex
CREATE UNIQUE INDEX "control_implementations_tenant_id_req_id_key" ON "control_implementations"("tenant_id", "req_id");
-- Row Level Security (zweite Verteidigungslinie, analog übrige Mandanten-Tabellen)
DO $$
DECLARE t text;
BEGIN
FOREACH t IN ARRAY ARRAY['control_implementations'] LOOP
EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY', t);
EXECUTE format(
'CREATE POLICY tenant_isolation ON %I USING (tenant_id = current_setting(''app.tenant_id'', true))',
t
);
END LOOP;
END $$;