ALTER TABLE admin_operation_logs
  ADD COLUMN request_id VARCHAR(64) NOT NULL DEFAULT '' AFTER id,
  ADD COLUMN resource_id VARCHAR(80) NOT NULL DEFAULT '' AFTER resource,
  ADD COLUMN user_agent VARCHAR(255) NOT NULL DEFAULT '' AFTER ip,
  ADD COLUMN http_status INT NOT NULL DEFAULT 0 AFTER status,
  ADD COLUMN risk_level VARCHAR(24) NOT NULL DEFAULT 'normal' AFTER http_status,
  ADD COLUMN latency_ms BIGINT NOT NULL DEFAULT 0 AFTER risk_level,
  ADD INDEX idx_admin_operation_logs_request_id (request_id),
  ADD INDEX idx_admin_operation_logs_resource_id (resource_id),
  ADD INDEX idx_admin_operation_logs_risk_level (risk_level);

ALTER TABLE admin_jobs
  ADD COLUMN attempt INT NOT NULL DEFAULT 0 AFTER error,
  ADD COLUMN max_attempts INT NOT NULL DEFAULT 3 AFTER attempt,
  ADD COLUMN locked_by VARCHAR(120) NOT NULL DEFAULT '' AFTER max_attempts,
  ADD COLUMN locked_until_ms BIGINT NULL AFTER locked_by,
  ADD COLUMN artifact_path VARCHAR(255) NOT NULL DEFAULT '' AFTER locked_until_ms,
  ADD INDEX idx_admin_jobs_locked_by (locked_by),
  ADD INDEX idx_admin_jobs_locked_until (locked_until_ms);
