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 code documentation for the migration stages.
Roadmap
(Note, these steps should be done roughly in order)
- T397269 Create a DB column for the country code, wait for it to exist in beta and production.
- T397544 Add a migration flag to the code, which should default to MIGRATION_OLD.
- 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 and fixing bugs: T397270).
- 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.
- T397636 Start purging unused address rows.
- 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.
- 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 MIGRATION_WRITE_BOTH as default in tests that use MIGRATION_OLD: r1173933
- Set the migration stage to MIGRATION_WRITE_BOTH in production, make sure it works. r1175507
- Run the migration script on all the DBs used by CampaignEvents, make sure it worked
- Set the migration stage to MIGRATION_WRITE_NEW as default in tests that use MIGRATION_WRITE_BOTH. r1175508
- T401336 Bump the default migration stage to MIGRATION_WRITE_BOTH
- T401336 Add the update script to update.php
- Set the migration stage to MIGRATION_WRITE_NEW in production, make sure it works. r1180858
- Set the migration stage to MIGRATION_NEW as default in tests that use MIGRATION_WRITE_NEW. r1180889
- Set the migration stage to MIGRATION_NEW in production, make sure it works. r1180890
- Wait for the MW 1.45 branch cut (first release after we introduced the migration flag), due 2025-10-28
- T408931 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.
- T408932 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.)