74 lines
3.1 KiB
MySQL
74 lines
3.1 KiB
MySQL
|
|
-- Migration 051: P-11 Legal-Hold Lifecycle-Status
|
||
|
|
-- Sofortsperrung fuer rechtlich problematische Medien (Compliance-Paket P-11)
|
||
|
|
--
|
||
|
|
-- Architekturentscheidung:
|
||
|
|
-- rights_status='blocked' bleibt als Spiegel-Schnellstatus (P-06-Kompatibilitaet).
|
||
|
|
-- Primaere Wahrheit: legal_hold_active + dedizierte Metadaten-Felder in media_assets.
|
||
|
|
-- Dies ermoeglicht klare Trennung: P-06 Deklarationsstatus / P-11 Legal Hold / P-03 Lifecycle.
|
||
|
|
-- P-13 kann spaeter denselben set_legal_hold-Service nutzen.
|
||
|
|
|
||
|
|
ALTER TABLE media_assets
|
||
|
|
ADD COLUMN IF NOT EXISTS legal_hold_active BOOLEAN NOT NULL DEFAULT FALSE,
|
||
|
|
ADD COLUMN IF NOT EXISTS legal_hold_reason_code VARCHAR(50)
|
||
|
|
CHECK (legal_hold_reason_code IN (
|
||
|
|
'rights_dispute',
|
||
|
|
'consent_withdrawn',
|
||
|
|
'privacy_complaint',
|
||
|
|
'copyright_complaint',
|
||
|
|
'youth_protection',
|
||
|
|
'illegal_content',
|
||
|
|
'other'
|
||
|
|
)),
|
||
|
|
ADD COLUMN IF NOT EXISTS legal_hold_reason_note TEXT,
|
||
|
|
ADD COLUMN IF NOT EXISTS legal_hold_set_by_profile_id INT REFERENCES profiles(id) ON DELETE SET NULL,
|
||
|
|
ADD COLUMN IF NOT EXISTS legal_hold_set_at TIMESTAMPTZ,
|
||
|
|
ADD COLUMN IF NOT EXISTS legal_hold_released_by_profile_id INT REFERENCES profiles(id) ON DELETE SET NULL,
|
||
|
|
ADD COLUMN IF NOT EXISTS legal_hold_released_at TIMESTAMPTZ,
|
||
|
|
ADD COLUMN IF NOT EXISTS legal_hold_release_note TEXT;
|
||
|
|
|
||
|
|
COMMENT ON COLUMN media_assets.legal_hold_active IS
|
||
|
|
'P-11: TRUE = Medium unter Legal Hold; sofortige Sperrung fuer alle normalen Nutzerpfade. '
|
||
|
|
'Retention-Job darf dieses Medium nicht purgen. '
|
||
|
|
'rights_status wird bei Aktivierung auf ''blocked'' gespiegelt.';
|
||
|
|
|
||
|
|
COMMENT ON COLUMN media_assets.legal_hold_reason_code IS
|
||
|
|
'P-11: Kategorie des Legal Holds. Pflicht beim Setzen.';
|
||
|
|
|
||
|
|
COMMENT ON COLUMN media_assets.legal_hold_reason_note IS
|
||
|
|
'P-11: Freitext-Begruendung fuer den Legal Hold.';
|
||
|
|
|
||
|
|
COMMENT ON COLUMN media_assets.legal_hold_set_by_profile_id IS
|
||
|
|
'P-11: Profil das den Legal Hold gesetzt hat (Superadmin).';
|
||
|
|
|
||
|
|
COMMENT ON COLUMN media_assets.legal_hold_set_at IS
|
||
|
|
'P-11: Zeitpunkt der Legal-Hold-Aktivierung.';
|
||
|
|
|
||
|
|
COMMENT ON COLUMN media_assets.legal_hold_released_by_profile_id IS
|
||
|
|
'P-11: Profil das den Legal Hold aufgehoben hat.';
|
||
|
|
|
||
|
|
COMMENT ON COLUMN media_assets.legal_hold_released_at IS
|
||
|
|
'P-11: Zeitpunkt der Legal-Hold-Freigabe.';
|
||
|
|
|
||
|
|
COMMENT ON COLUMN media_assets.legal_hold_release_note IS
|
||
|
|
'P-11: Begruendung fuer die Aufhebung des Legal Holds.';
|
||
|
|
|
||
|
|
-- Index fuer Admin-Liste aktiver Legal Holds
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_media_assets_legal_hold_active
|
||
|
|
ON media_assets (legal_hold_active)
|
||
|
|
WHERE legal_hold_active = TRUE;
|
||
|
|
|
||
|
|
-- Neue event_types fuer media_asset_audit_log
|
||
|
|
ALTER TABLE media_asset_audit_log
|
||
|
|
DROP CONSTRAINT IF EXISTS media_asset_audit_log_event_type_check;
|
||
|
|
|
||
|
|
ALTER TABLE media_asset_audit_log
|
||
|
|
ADD CONSTRAINT media_asset_audit_log_event_type_check
|
||
|
|
CHECK (event_type IN (
|
||
|
|
'visibility_change',
|
||
|
|
'copyright_change',
|
||
|
|
'metadata_change',
|
||
|
|
'lifecycle_change',
|
||
|
|
'legal_hold_set',
|
||
|
|
'legal_hold_released'
|
||
|
|
));
|