-- Baltique OS Core 0.78.42 — Enterprise UI Accessibility & Usability Audit
-- Reference SQL. Runtime upgrade is idempotent and schema-safe.
CREATE TABLE IF NOT EXISTS enterprise_ui_audit_rules (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, rule_key VARCHAR(120) NOT NULL, rule_label VARCHAR(190) NOT NULL, severity VARCHAR(40) NOT NULL DEFAULT 'warning', active TINYINT(1) NOT NULL DEFAULT 1, evidence_json JSON NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NULL, PRIMARY KEY(id), UNIQUE KEY uq_enterprise_ui_audit_rules_key (rule_key)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS enterprise_ui_audit_findings (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, finding_uuid VARCHAR(80) NOT NULL, rule_key VARCHAR(120) NOT NULL, file_path VARCHAR(255) NULL, status VARCHAR(40) NOT NULL DEFAULT 'open', severity VARCHAR(40) NOT NULL DEFAULT 'warning', message TEXT NULL, evidence_json JSON NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NULL, PRIMARY KEY(id), UNIQUE KEY uq_enterprise_ui_audit_findings_uuid (finding_uuid), KEY idx_enterprise_ui_audit_findings_status (status,severity)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS enterprise_ui_audit_runs (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, run_uuid VARCHAR(80) NOT NULL, status VARCHAR(40) NOT NULL DEFAULT 'OK', findings INT NOT NULL DEFAULT 0, critical_findings INT NOT NULL DEFAULT 0, evidence_json JSON NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NULL, PRIMARY KEY(id), UNIQUE KEY uq_enterprise_ui_audit_runs_uuid (run_uuid)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
