Files
breakpilot-compliance/backend-compliance/migrations/009_consent_history.sql
Benjamin Admin 393eab6acd
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 36s
CI / test-python-backend-compliance (push) Successful in 31s
CI / test-python-document-crawler (push) Successful in 23s
CI / test-python-dsms-gateway (push) Successful in 18s
feat: Package 4 Nachbesserungen — History-Tracking, Pagination, Frontend-Fixes
Backend:
- Migration 009: compliance_einwilligungen_consent_history Tabelle
- EinwilligungenConsentHistoryDB Modell (consent_id, action, version, ip, ua, source)
- _record_history() Helper: automatisch bei POST /consents (granted) + PUT /revoke (revoked)
- GET /consents/{id}/history Endpoint (vor revoke platziert für korrektes Routing)
- GET /consents: history-Array pro Eintrag (inline Sub-Query)
- 5 neue Tests (TestConsentHistoryTracking) — 32/32 bestanden

Frontend:
- consent/route.ts: limit+offset aus Frontend-Request weitergeleitet, total-Feld ergänzt
- Neuer Proxy consent/[id]/history/route.ts für GET /consents/{id}/history
- page.tsx: globalStats state + loadStats() (Backend /consents/stats für globale Zahlen)
- page.tsx: Stats-Kacheln auf globalStats umgestellt (nicht mehr page-relativ)
- page.tsx: history-Mapper: created_at→timestamp, consent_version→version
- page.tsx: loadStats() bei Mount + nach Revoke

Dokumentation:
- Developer Portal: neue API-Docs-Seite /api/einwilligungen (Consent + Legal Docs + Cookie Banner)
- developer-portal/app/api/page.tsx: Consent Management Abschnitt
- MkDocs: History-Endpoint, Pagination-Abschnitt, History-Tracking Abschnitt
- Deploy-Skript: scripts/apply_consent_history_migration.sh

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

21 lines
991 B
SQL

-- Migration 009: Consent History Tracking
-- Protokolliert alle Aenderungen an Einwilligungen (granted, revoked, version_update, renewed)
-- Wird automatisch bei POST /consents (granted) und PUT /consents/{id}/revoke (revoked) befuellt
SET search_path TO compliance, core, public;
CREATE TABLE IF NOT EXISTS compliance_einwilligungen_consent_history (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
consent_id UUID NOT NULL,
tenant_id VARCHAR(100) NOT NULL,
action VARCHAR(50) NOT NULL, -- granted | revoked | version_update | renewed
consent_version VARCHAR(20),
ip_address VARCHAR(45),
user_agent TEXT,
source VARCHAR(100),
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_einw_history_consent ON compliance_einwilligungen_consent_history(consent_id);
CREATE INDEX IF NOT EXISTS idx_einw_history_tenant ON compliance_einwilligungen_consent_history(tenant_id);