UPDATE membership_plans
SET tier = 'YOUTH'
WHERE membership_type = 'INDIVIDUAL'
  AND tier = 'STARTER';

UPDATE membership_plans
SET
  tier = CASE
    WHEN organization_type = 'SCHOOL' THEN 'EDUCATION'::membership_plan_tier_enum
    WHEN organization_type = 'GRASSROOTS_ROSCA' THEN 'GRASSROOT'::membership_plan_tier_enum
    WHEN organization_type = 'NFP_ALUMNI_FAITH' THEN 'COMMUNITY'::membership_plan_tier_enum
    WHEN name ILIKE '%school%' OR name ILIKE '%education%' THEN 'EDUCATION'::membership_plan_tier_enum
    WHEN name ILIKE '%grassroot%' OR name ILIKE '%rosca%' THEN 'GRASSROOT'::membership_plan_tier_enum
    ELSE 'COMMUNITY'::membership_plan_tier_enum
  END,
  organization_type = NULL
WHERE membership_type = 'ORGANIZATION';

UPDATE membership_plans
SET tier = CASE
  WHEN name ILIKE '%worker%' THEN 'WORKER'::membership_plan_tier_enum
  WHEN name ILIKE '%impact%' THEN 'IMPACT'::membership_plan_tier_enum
  WHEN name ILIKE '%sponsor%' OR name ILIKE '%capital%' THEN 'SPONSOR'::membership_plan_tier_enum
  WHEN tier = 'STARTER' THEN 'WORKER'::membership_plan_tier_enum
  WHEN tier = 'ELITE' THEN 'IMPACT'::membership_plan_tier_enum
  ELSE 'SPONSOR'::membership_plan_tier_enum
END
WHERE membership_type = 'INVESTOR';
