Skip to content

campaigns: migrate pre-spec campaigns to have specs

Administrator requested to merge aharvey/campaign-spec-migration into main

Created by: LawnGnome

This will fix #12641, and close #12640 as moot. (Although we could wire something up in the future to download the generated spec files if someone needed them, since they're in the database.)

General approach

We're going to move pre-spec campaign and changeset records into tables imaginatively called campaigns_old and changesets_old, then abuse repo-updater to automagically transfer as much as we can to the new world by writing campaign and changeset specs for the user.

This allows us to make a few more fields NOT NULL on the campaigns table, which is always a party. 🎈

Automagic

The interesting bit from a review perspective is probably the new migration function that's invoked when repo-updater starts. It's pure spaghetti, but rather like ApplyCampaign, this is mostly because it's just a big linear process that needs to happen in order.

Noise

There's a fair bit of testing noise from making the campaign fields not nullable, but that's fairly mechanical. We just need more fields set when we're mocking campaigns, and some of those fields require real spec and user records, since we have foreign keys. (There are times where I yearn for the pure yolo of MySQL circa 1999.)

Testing

To state the obvious, if you want to be able to return to the exact database you had before the migration process, you should back it up first. Migrating down works just fine, but the pre-spec campaigns don't go back to their old form, since it's a destructive process. (They are, however, totally usable.)

Merge request reports

Loading