-- Adds indexes for the join/sort columns listAppeals() (the "Manage
-- Appeals" query) uses on every load, regardless of filters. None of these
-- columns had any index beyond the primary key, so every join fell back to
-- a full table scan; with production-scale data (~14k appeals) that made
-- the unfiltered listing take several seconds. Purely additive — no
-- behavior change, only query plan/speed.

ALTER TABLE `appeal`
  ADD INDEX `appeal_type` (`appeal_type`),
  ADD INDEX `relevant_appeal` (`relevant_appeal`),
  ADD INDEX `created` (`created`);

ALTER TABLE `appeal_appeal_category`
  ADD INDEX `appeal` (`appeal`),
  ADD INDEX `appeal_category` (`appeal_category`);

ALTER TABLE `appeal_level_2`
  ADD INDEX `relevant_appeal` (`relevant_appeal`);

-- appeal is also used by course-based category lookups (loadAppealData(),
-- loadAppealCategoryIds()); appeal_category is used by listAppeals()'s
-- category filter (matches courses tagged with the filtered category).
ALTER TABLE `course`
  ADD INDEX `appeal` (`appeal`),
  ADD INDEX `appeal_category` (`appeal_category`);
