-- Migration 106: Banner Email Linking + Consent Proof -- Phase 3: linked_email for DSR ↔ Banner-Consent correlation -- Phase 6: banner_config_hash + consent_version for Art. 7(1) DSGVO proof -- 1. Add linked_email to banner consents (optional, nullable) -- Allows correlating device-based consents with user email for DSR processing ALTER TABLE compliance_banner_consents ADD COLUMN IF NOT EXISTS linked_email TEXT; CREATE INDEX IF NOT EXISTS idx_banner_consent_email ON compliance_banner_consents (linked_email) WHERE linked_email IS NOT NULL; -- 2. Add consent proof columns to audit log -- banner_config_hash: SHA256 of the site config at consent time (Art. 7(1) DSGVO) -- consent_version: incremented per site on config change, tracks which banner version was shown ALTER TABLE compliance_banner_consent_audit_log ADD COLUMN IF NOT EXISTS banner_config_hash TEXT, ADD COLUMN IF NOT EXISTS consent_version INTEGER; -- 3. Add config_version counter to site configs (auto-incremented on config change) ALTER TABLE compliance_banner_site_configs ADD COLUMN IF NOT EXISTS config_version INTEGER NOT NULL DEFAULT 1;