ALTER TABLE inquiries
  ADD COLUMN IF NOT EXISTS closed_at DATETIME NULL AFTER replied_at,
  ADD COLUMN IF NOT EXISTS lookup_failed_attempts TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER closed_at,
  ADD COLUMN IF NOT EXISTS lookup_locked_until DATETIME NULL AFTER lookup_failed_attempts;

ALTER TABLE inquiries
  DROP INDEX IF EXISTS idx_inquiries_retention,
  ADD INDEX idx_inquiries_retention (closed_at, deleted_at);
