Files
breakpilot-compliance/backend-compliance/migrations/031_modules.sql
Benjamin Admin 3913931d5b
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 40s
CI / test-python-backend-compliance (push) Successful in 34s
CI / test-python-document-crawler (push) Successful in 26s
CI / test-python-dsms-gateway (push) Successful in 21s
feat(freigabe): Import/Screening/Modules/RAG — API-Tests, Migration 031, Bug-Fix
- import_routes: GET /gap-analysis/{document_id} implementiert
- import_routes: Bug-Fix — gap_analysis_result vor try-Block initialisiert
  (verhindert UnboundLocalError bei DB-Fehler)
- test_import_routes: 21 neue API-Endpoint-Tests (59 total, alle grün)
- test_screening_routes: 18 neue API-Endpoint-Tests (74 total, alle grün)
- 031_modules.sql: Migration für compliance_service_modules,
  compliance_module_regulations, compliance_module_risks
- test_module_routes: 20 neue Tests für Module-Registry-Routen (alle grün)
- freigabe-module.md: MkDocs-Seite für Import/Screening/Modules/RAG
- mkdocs.yml: Nav-Eintrag "Freigabe-Module (Paket 2)"

Gesamt: 146 neue Tests, alle bestanden

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

83 lines
2.9 KiB
SQL

-- Migration 031: Service Module Registry Tables
-- Creates tables for compliance_service_modules, compliance_module_regulations,
-- and compliance_module_risks (aligned with SQLAlchemy models in db/models.py).
CREATE TABLE IF NOT EXISTS compliance_service_modules (
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::TEXT,
name TEXT NOT NULL UNIQUE,
display_name TEXT NOT NULL,
description TEXT,
-- Technical details
service_type TEXT,
port INTEGER,
technology_stack JSONB DEFAULT '[]',
repository_path TEXT,
docker_image TEXT,
-- Data categories
data_categories JSONB DEFAULT '[]',
processes_pii BOOLEAN DEFAULT FALSE,
processes_health_data BOOLEAN DEFAULT FALSE,
ai_components BOOLEAN DEFAULT FALSE,
-- Status & compliance
is_active BOOLEAN DEFAULT TRUE,
criticality TEXT DEFAULT 'medium',
compliance_score FLOAT,
last_compliance_check TIMESTAMPTZ,
-- Owner
owner_team TEXT,
owner_contact TEXT,
-- Timestamps
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS ix_module_type_active
ON compliance_service_modules (service_type, is_active);
-- Regulation mappings (module → regulation with relevance level)
CREATE TABLE IF NOT EXISTS compliance_module_regulations (
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::TEXT,
module_id TEXT NOT NULL REFERENCES compliance_service_modules(id) ON DELETE CASCADE,
regulation_id TEXT NOT NULL REFERENCES compliance_regulations(id) ON DELETE CASCADE,
relevance_level TEXT NOT NULL DEFAULT 'medium',
notes TEXT,
applicable_articles JSONB DEFAULT '[]',
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
CONSTRAINT uq_module_regulation UNIQUE (module_id, regulation_id)
);
CREATE INDEX IF NOT EXISTS ix_module_regulation_module
ON compliance_module_regulations (module_id);
CREATE INDEX IF NOT EXISTS ix_module_regulation_regulation
ON compliance_module_regulations (regulation_id);
-- Module risks (module → risk with module-specific assessment)
CREATE TABLE IF NOT EXISTS compliance_module_risks (
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::TEXT,
module_id TEXT NOT NULL REFERENCES compliance_service_modules(id) ON DELETE CASCADE,
risk_id TEXT NOT NULL REFERENCES compliance_risks(id) ON DELETE CASCADE,
module_likelihood INTEGER,
module_impact INTEGER,
module_risk_level TEXT,
assessment_notes TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
CONSTRAINT uq_module_risk UNIQUE (module_id, risk_id)
);
CREATE INDEX IF NOT EXISTS ix_module_risk_module
ON compliance_module_risks (module_id);