This task outlines a roadmap for updating the database and storage layer so that the "event country" field:
# Uses a valid country code instead of free text
# Becomes required
# Is no longer repeated inside the "full address" field
See https://www.mediawiki.org/wiki/User:ASarabadani_(WMF)/Database_for_devs_toolkit/How-to/Data_migration for a detailed description of individual steps, as well as the [[https://github.com/wikimedia/mediawiki/blob/555fbd0f752bfe8d36de1de97b024e42bc03c84b/includes/Defines.php#L288-L350 | code documentation ]] for the migration stages.
===Roadmap===
(Note, these steps should be done roughly in order)
[x] T397269 Create a DB column for the country code, **wait** for it to exist in beta and production.
[x] T397544 Add a migration flag to the code, which should default to read_old + write_old.
[x] T397270 Write a script to backfill the new schema from old data. (This will be run later on)
[] Test the script in production **using dry-run**. Iterate on the script (e.g., adding more special cases as needed).
[x] Confirm that we will force a default value (or make the event not in-person) for events that either have no country, or have a country that we can't automatically convert to a country code.
[x] T397636 Start purging unused address rows.
[x] T397273 Update the storage layer code so that everything country-related (reads and writes) works for all the possible migration flag combinations.
[] T397867 Update the entity layer (EventRegistration, Address, EventFactory) so that everything country-related (reads and writes) works for all the possible migration flag combinations.
[] T397271, T397274, T397275, T397276 Update UI and API code to work for all possible migration stages.
[] Wait for the updated code (all tasks above) to reach production
[] Set the migration stage to read_both + write_both as default in tests that use MIGRATION_OLD.
[] Set the migration stage to read_both + write_both in production, make sure it works.
[] Set the migration stage to read_both + write_new as default in tests that use read_both + write_both.
[] Set the migration stage to read_both + write_new in production, make sure it works.
[] Run the migration script on all the DBs used by CampaignEvents, make sure it worked
[] Add the script to update.php, or if the script is destructive, maybe just add a note to update.php that it should be run manually
[] Set the migration stage to read_new + write_new as default in tests that use read_both + write_new .
[] Set the migration stage to read_new + write_new in production, make sure it works.
[] Wait for the first MW release after we introduced the migration flag
[] **Depending on handling of historical data**: clean up the old schema. Make the new column not nullable, drop the old column. Make sure the change is applied in beta and production.
[] Drop the migration flag and associated code + misc clean-ups (e.g. make things not nullable in the code; drop temporary methods; make sure in-person/hybrid events have an Address object; perhaps add a getAddressOfOnlineEvent() for type safety that returns Address or throws; etc.)