-- Seed the "benefactor" badge — an honorary one-shot medal for people who
-- contributed to the project.
--
-- Design:
--   - `type = 'unique'` (single tier at level 1). Purely a distinction, not
--     tied to any tracked metric: no award path emits it. The `metric` column
--     is NOT NULL, so it carries the placeholder `manual.benefactor` — a value
--     no BadgeMetric caller ever emits, which makes it unambiguous that this
--     badge is granted by hand via `PUT /admin/users/{hex}/badges/benefactor`.
--   - `xp_reward = 0`: manual admin grants award no XP anyway (see
--     AssignUserBadgeAction), and this badge is honorary — no economy impact.
--   - `position = 60` slots it after "pioneer" (50).
--   - No `category_id`: left uncategorised (the BO can file it later via the
--     badge CRUD).
--
-- Idempotency: INSERT IGNORE + slug-as-natural-key make the migration safe to
-- re-run. The tier row resolves `badge_id` by slug.

INSERT IGNORE INTO `badge`
    (`id`, `slug`, `type`, `metric`, `position`, `is_active`, `created_at`)
VALUES
    (UNHEX(REPLACE(UUID(), '-', '')),
     'benefactor',
     'unique',
     'manual.benefactor',
     60,
     1,
     NOW());

INSERT IGNORE INTO `badge_tier`
    (`badge_id`, `level`, `threshold`, `xp_reward`)
SELECT `id`, 1, 1, 0
  FROM `badge`
 WHERE `slug` = 'benefactor';
