hcb icon indicating copy to clipboard operation
hcb copied to clipboard

[1/4] Migrate from CountryEnumable to ISO3166::Country Alpha2

Open manuthecoder opened this issue 1 year ago • 0 comments

🔁 Migrate from CountryEnumable to ISO3166::Country Alpha2 (1/4)

🧠 Context

We're deprecating our custom CountryEnumable::country_enum_list (which maps countries to integers) in favor of ISO3166::Country, which uses standard alpha2 codes ("US", "IN", etc.). This shift will simplify country handling across the codebase and reduce redundancy.

This is Step 1 of a 4 part migration process


✅ Changes in this PR

  • Adds new country_alpha2 (string) columns via migration:
    • events.country_alpha2
    • wires.country_alpha2
  • Adds before_save hooks to auto-populate country_alpha2 based on existing:
    • event.country
    • wire.recipient_country
  • Removes:
    • include CountryEnumable
    • has_country_enum from the Event model to begin decoupling from the legacy enum system.

Overview

  1. Add country_alpha2 columns + save hooks (this PR ✅
  2. Backfill alpha2 values from existing integer data
  3. Update app logic to use country_alpha2 (UI, filters, validations)
  4. Drop old enum fields + delete CountryEnumable

Existing behavior using event.country or wire.recipient_country should remain intact for now

manuthecoder avatar Feb 06 '25 22:02 manuthecoder