-- Reversible lifecycle for large automation-rule libraries.
ALTER TABLE vehicle_alert_rule
  ADD COLUMN archived_by VARCHAR(128) NOT NULL DEFAULT '' AFTER updated_by,
  ADD COLUMN archived_at DATETIME(3) NULL AFTER archived_by,
  ADD COLUMN archive_reason VARCHAR(200) NOT NULL DEFAULT '' AFTER archived_at,
  ADD KEY idx_alert_rule_lifecycle (archived_at, enabled, updated_at);

ALTER TABLE vehicle_alert_rule_audit
  ADD COLUMN reason VARCHAR(200) NOT NULL DEFAULT '' AFTER action;
