-- Migration 011: Compliance Escalations
-- Erstellt: 2026-03-03

CREATE TABLE IF NOT EXISTS compliance_escalations (
    id          UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    tenant_id   VARCHAR(100) NOT NULL DEFAULT 'default',
    title       TEXT NOT NULL,
    description TEXT,
    priority    VARCHAR(20) DEFAULT 'medium',
    status      VARCHAR(30) DEFAULT 'open',
    category    VARCHAR(50),
    assignee    VARCHAR(200),
    reporter    VARCHAR(200),
    source_module VARCHAR(100),
    source_id   UUID,
    due_date    TIMESTAMP,
    resolved_at TIMESTAMP,
    created_at  TIMESTAMP DEFAULT NOW(),
    updated_at  TIMESTAMP DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_escalations_tenant ON compliance_escalations(tenant_id);
CREATE INDEX IF NOT EXISTS idx_escalations_status ON compliance_escalations(status);
CREATE INDEX IF NOT EXISTS idx_escalations_priority ON compliance_escalations(priority);
