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)
[x] Test the script in production **using dry-run**. Iterate on the script (e.g., adding more special cases as needed and fixing bugs: T397270).
[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.
[x] T397867 Update the entity layer (EventRegistration, Address, EventFactory) so that everything country-related (reads and writes) works for all the possible migration flag combinations.
[x] Update UI and API code to work for all possible migration stages:
- [x] T397271
- [x] T397274
- [x] T397275
- [x] T397276
- [x] T400254
[x] Wait for the updated code (all tasks above) to reach production
[x] Set the migration stage to read_both + write_both as default in tests that use MIGRATION_OLD: [[https://gerrit.wikimedia.org/r/1173933 | r1173933]]
[x] Set the migration stage to read_both + write_both in production, make sure it works. [[https://gerrit.wikimedia.org/r/c/operations/mediawiki-config/+/1175507 | r1175507]]
[x] Run the migration script on all the DBs used by CampaignEvents, make sure it worked
[x] Set the migration stage to read_both + write_new as default in tests that use read_both + write_both. [[https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CampaignEvents/+/1175508 | r1175508]]
[] Bump the default migration stage to MIGRATION_WRITE_BOTH
[] Add the update 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_both + write_new in production, make sure it works.
[] 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
[] 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.)