Run populateContentTables.php from update.php
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 10 Jul 2018 17:09:37 +0000 (13:09 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 10 Jul 2018 17:13:26 +0000 (13:13 -0400)
Since update.php will eventually be dropping the old columns and fields,
we should make sure the migration script gets run first.

Bug: T197818
Change-Id: I47f5ba4e21b4fe2ef0beb9fc83896cd4b0a0d505

includes/installer/DatabaseUpdater.php
includes/installer/MssqlUpdater.php
includes/installer/MysqlUpdater.php
includes/installer/OracleUpdater.php
includes/installer/PostgresUpdater.php
includes/installer/SqliteUpdater.php
maintenance/populateContentTables.php

index 939301d..bf140ea 100644 (file)
@@ -1362,4 +1362,29 @@ abstract class DatabaseUpdater {
                        $this->output( "done.\n" );
                }
        }
+
+       /**
+        * Populates the MCR content tables
+        * @since 1.32
+        */
+       protected function populateContentTables() {
+               global $wgMultiContentRevisionSchemaMigrationStage;
+               if ( ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) &&
+                       !$this->updateRowExists( 'PopulateContentTables' )
+               ) {
+                       $this->output(
+                               "Migrating revision data to the MCR 'slot' and 'content' tables, printing progress markers.\n" .
+                               "For large databases, you may want to hit Ctrl-C and do this manually with\n" .
+                               "maintenance/populateContentTables.php.\n"
+                       );
+                       $task = $this->maintenance->runChild(
+                               PopulateContentTables::class, 'populateContentTables.php'
+                       );
+                       $ok = $task->execute();
+                       $this->output( $ok ? "done.\n" : "errors were encountered.\n" );
+                       if ( $ok ) {
+                               $this->insertUpdateRow( 'PopulateContentTables' );
+                       }
+               }
+       }
 }
index cfa21f4..485d758 100644 (file)
@@ -137,6 +137,7 @@ class MssqlUpdater extends DatabaseUpdater {
                        [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
                        [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
                        [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
+                       [ 'populateContentTables' ],
                ];
        }
 
index f8114e3..b52cfb1 100644 (file)
@@ -358,6 +358,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
                        [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
                        [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
+                       [ 'populateContentTables' ],
                ];
        }
 
index 9d2fdc6..c9ed53f 100644 (file)
@@ -154,6 +154,7 @@ class OracleUpdater extends DatabaseUpdater {
                        [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
                        [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
                        [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
+                       [ 'populateContentTables' ],
 
                        // KEEP THIS AT THE BOTTOM!!
                        [ 'doRebuildDuplicateFunction' ],
index dc1ffdb..b12bd55 100644 (file)
@@ -584,6 +584,7 @@ class PostgresUpdater extends DatabaseUpdater {
                        ],
                        [ 'addPgIndex', 'archive', 'ar_revid_uniq', '(ar_rev_id)', 'unique' ],
                        [ 'dropPgIndex', 'archive', 'ar_revid' ], // Probably doesn't exist, but do it anyway.
+                       [ 'populateContentTables' ],
                ];
        }
 
index fd9179b..d7713cb 100644 (file)
@@ -222,6 +222,7 @@ class SqliteUpdater extends DatabaseUpdater {
                        [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
                        [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
                        [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
+                       [ 'populateContentTables' ],
                ];
        }
 
index b550cc2..5322b5b 100644 (file)
@@ -92,6 +92,7 @@ class PopulateContentTables extends Maintenance {
 
                $elapsed = microtime( true ) - $t0;
                $this->writeln( "Done. Processed $this->totalCount rows in $elapsed seconds" );
+               return true;
        }
 
        /**