We need to do the following (see comments for details of earlier work):
We'll need DBA assistance for 'Remove the old indexes'. The Collaboration team will do everything else before that.
[X] Create temporary indices [patch-reference_wiki-phase2.sql](https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FFlow.git/ 65307c7a3c87d27443a2bf29f9573cea6be05182/db_patches%2Fpatch-reference_wiki-phase2.sql)
[X] Apply [patch-reference_wiki-phase3.sql](https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FFlow.git/ 65307c7a3c87d27443a2bf29f9573cea6be05182/db_patches%2Fpatch-reference_wiki-phase3.sql). This patch will back-fill the field. It must be run repeatedly until 0 rows are affected for all the updates.
[X] Apply [patch-reference_wiki-phase4.sql](https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FFlow.git/ 65307c7a3c87d27443a2bf29f9573cea6be05182/db_patches%2Fpatch-reference_wiki-phase4.sql). This patch will set the columns NOT NULL
[x] Verify the v2 indexes exist on the tables
[ ] Turn off `$wgFlowMigrateReferenceWiki` in beta and verify nothing bad happens (https://gerrit.wikimedia.org/r/#/c/234207)
[ ] Verify there are no rows in production (either flowdb or officewiki) with NULL or '' ref_src_wiki values in either table.
[ ] Turn off `$wgFlowMigrateReferenceWiki` in production (https://gerrit.wikimedia.org/r/#/c/238111/)
[ ] Verify that the queries being issued all hit the v2 indexes
[ ] Remove the old indexes by running [patch-reference_wiki-phase5.sql](https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FFlow.git/65307c7a3c87d27443a2bf29f9573cea6be05182/db_patches%2Fpatch-reference_wiki-phase5.sql).
This needs to be done in flowdb and all private wikis with Flow (officewiki).