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.
- 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)
- 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.
- 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
- Verify the v2 indexes exist on the tables
- Turn off $wgFlowMigrateReferenceWiki in beta (https://gerrit.wikimedia.org/r/#/c/234207)
- Verify nothing bad happens in Beta (especially performance-wise).
- 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 (in progress, see https://phabricator.wikimedia.org/T111084#1672606 ).
- Remove the old indexes by running patch-reference_wiki-phase5.sql (T113778).
This needs to be done in flowdb and all private wikis with Flow (officewiki).