Files
breakpilot-compliance/backend-compliance/migrations/008_einwilligungen.sql
Benjamin Admin 113ecdfa77
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 46s
CI / test-python-backend-compliance (push) Successful in 32s
CI / test-python-document-crawler (push) Successful in 22s
CI / test-python-dsms-gateway (push) Successful in 17s
feat: Package 4 Rechtliche Texte — DB-Persistenz fuer Legal Documents, Einwilligungen und Cookie Banner
- Migration 007: compliance_legal_documents, _versions, _approvals (Approval-Workflow)
- Migration 008: compliance_einwilligungen_catalog, _company, _cookies, _consents
- Backend: legal_document_routes.py (11 Endpoints + draft→review→approved→published Workflow)
- Backend: einwilligungen_routes.py (10 Endpoints inkl. Stats, Pagination, Revoke)
- Frontend: /api/admin/consent/[[...path]] Catch-All-Proxy fuer Legal Documents
- Frontend: catalog/consent/cookie-banner routes von In-Memory auf DB-Proxy umgestellt
- Frontend: einwilligungen/page.tsx + cookie-banner/page.tsx laden jetzt via API (kein Mock)
- Tests: 44/44 pass (test_legal_document_routes.py + test_einwilligungen_routes.py)
- Deploy-Scripts: apply_legal_docs_migration.sh + apply_einwilligungen_migration.sh

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 08:25:13 +01:00

52 lines
2.2 KiB
SQL

-- =========================================================
-- Migration 008: Einwilligungen — Consent-Tracking & Cookie-Banner
-- =========================================================
-- Tenant-Katalog: Welche Datenpunkte sind aktiv?
CREATE TABLE IF NOT EXISTS compliance_einwilligungen_catalog (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id VARCHAR(100) NOT NULL UNIQUE,
selected_data_point_ids JSONB DEFAULT '[]',
custom_data_points JSONB DEFAULT '[]',
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Firmeninformationen fuer DSI-Generierung
CREATE TABLE IF NOT EXISTS compliance_einwilligungen_company (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id VARCHAR(100) NOT NULL UNIQUE,
data JSONB NOT NULL DEFAULT '{}',
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Cookie-Banner-Konfiguration (persistiert)
CREATE TABLE IF NOT EXISTS compliance_einwilligungen_cookies (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id VARCHAR(100) NOT NULL UNIQUE,
categories JSONB DEFAULT '[]',
config JSONB DEFAULT '{}',
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Consent-Aufzeichnungen (Endnutzer-Einwilligungen)
CREATE TABLE IF NOT EXISTS compliance_einwilligungen_consents (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id VARCHAR(100) NOT NULL,
user_id VARCHAR(200) NOT NULL,
data_point_id VARCHAR(100) NOT NULL,
granted BOOLEAN NOT NULL DEFAULT TRUE,
granted_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
revoked_at TIMESTAMPTZ,
ip_address VARCHAR(45),
user_agent TEXT,
consent_version VARCHAR(20) DEFAULT '1.0',
source VARCHAR(100),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_einw_consents_tenant ON compliance_einwilligungen_consents(tenant_id);
CREATE INDEX IF NOT EXISTS idx_einw_consents_user ON compliance_einwilligungen_consents(tenant_id, user_id);
CREATE INDEX IF NOT EXISTS idx_einw_consents_dpid ON compliance_einwilligungen_consents(data_point_id);
CREATE INDEX IF NOT EXISTS idx_einw_catalog_tenant ON compliance_einwilligungen_catalog(tenant_id);
CREATE INDEX IF NOT EXISTS idx_einw_cookies_tenant ON compliance_einwilligungen_cookies(tenant_id);