31require_once __DIR__ .
'/../../maintenance/Maintenance.php';
86 DeleteDefaultMessages::class,
87 PopulateRevisionLength::class,
88 PopulateRevisionSha1::class,
89 PopulateImageSha1::class,
90 FixExtLinksProtocolRelative::class,
91 PopulateFilearchiveSha1::class,
92 PopulateBacklinkNamespace::class,
93 FixDefaultJsonContentPages::class,
94 CleanupEmptyCategories::class,
95 AddRFCandPMIDInterwiki::class,
96 PopulatePPSortKey::class,
97 PopulateIpChanges::class,
98 RefreshExternallinksIndex::class,
135 $this->maintenance->
setDB( $db );
144 (
new HookRunner( $hookContainer ) )->onLoadExtensionSchemaUpdates( $this );
152 global $wgExtNewTables, $wgExtNewFields, $wgExtPGNewFields,
153 $wgExtPGAlteredFields, $wgExtNewIndexes, $wgExtModifiedFields;
155 # For extensions only, should be populated via hooks
156 # $wgDBtype should be checked to specify the proper file
157 $wgExtNewTables = [];
158 $wgExtNewFields = [];
159 $wgExtPGNewFields = [];
160 $wgExtPGAlteredFields = [];
161 $wgExtNewIndexes = [];
162 $wgExtModifiedFields = [];
172 if ( $this->autoExtensionHookContainer ) {
174 return $this->autoExtensionHookContainer;
176 if ( defined(
'MW_EXTENSIONS_LOADED' ) ) {
177 throw new Exception( __METHOD__ .
178 ' apparently called from installer but no hook container was injected' );
180 if ( !defined(
'MEDIAWIKI_INSTALL' ) ) {
182 return MediaWikiServices::getInstance()->getHookContainer();
186 $registry = ExtensionRegistry::getInstance();
187 $queue = $registry->getQueue();
189 $registry->clearQueue();
192 $data = $registry->readFromQueue(
$queue );
196 $legacySchemaHooks = $data[
'globals'][
'wgHooks'][
'LoadExtensionSchemaUpdates'] ?? [];
197 if ( $vars && isset( $vars[
'wgHooks'][
'LoadExtensionSchemaUpdates'] ) ) {
198 $legacySchemaHooks = array_merge( $legacySchemaHooks, $vars[
'wgHooks'][
'LoadExtensionSchemaUpdates'] );
203 if ( $vars && isset( $vars[
'wgAutoloadClasses'] ) ) {
209 [
'LoadExtensionSchemaUpdates' => $legacySchemaHooks ],
210 $data[
'attributes'][
'Hooks'] ?? [],
211 $data[
'attributes'][
'DeprecatedHooks'] ?? []
213 MediaWikiServices::getInstance()->getObjectFactory()
232 $class = ucfirst(
$type ) .
'Updater';
236 throw new MWException( __METHOD__ .
' called for unsupported $wgDBtype' );
248 $this->autoExtensionHookContainer = $hookContainer;
267 if ( $this->maintenance->isQuiet() ) {
272 $str = htmlspecialchars( $str );
291 $this->extensionUpdates[] = $update;
305 $this->extensionUpdates[] = [
'addTable', $tableName, $sqlPath,
true ];
319 $this->extensionUpdates[] = [
'addIndex', $tableName, $indexName, $sqlPath,
true ];
333 $this->extensionUpdates[] = [
'addField', $tableName, $columnName, $sqlPath,
true ];
347 $this->extensionUpdates[] = [
'dropField', $tableName, $columnName, $sqlPath,
true ];
361 $this->extensionUpdates[] = [
'dropIndex', $tableName, $indexName, $sqlPath,
true ];
374 $this->extensionUpdates[] = [
'dropTable', $tableName, $sqlPath,
true ];
391 $sqlPath, $skipBothIndexExistWarning =
false
393 $this->extensionUpdates[] = [
398 $skipBothIndexExistWarning,
415 $this->extensionUpdates[] = [
'modifyField', $tableName, $fieldName, $sqlPath,
true ];
428 $this->extensionUpdates[] = [
'modifyTable', $tableName, $sqlPath,
true ];
438 return ( $this->db->tableExists( $tableName, __METHOD__ ) );
451 $this->postDatabaseUpdateMaintenance[] = $class;
460 return $this->extensionUpdates;
469 return $this->postDatabaseUpdateMaintenance;
480 $this->updatesSkipped = [];
483 list( $func,
$args, $origParams ) = $funcList;
487 $this->updatesSkipped[] = $origParams;
511 public function doUpdates( array $what = [
'core',
'extensions',
'stats' ] ) {
514 $what = array_flip( $what );
515 $this->skipSchema = isset( $what[
'noschema'] ) || $this->fileHandle !==
null;
516 if ( isset( $what[
'core'] ) ) {
519 if ( isset( $what[
'extensions'] ) ) {
525 if ( isset( $what[
'stats'] ) ) {
529 if ( $this->fileHandle ) {
530 $this->skipSchema =
false;
542 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
546 foreach ( $updates as $params ) {
547 $origParams = $params;
548 $func = array_shift( $params );
549 if ( !is_array( $func ) && method_exists( $this, $func ) ) {
550 $func = [ $this, $func ];
551 } elseif ( $passSelf ) {
552 array_unshift( $params, $this );
554 $ret = $func( ...$params );
556 if ( $ret !==
false ) {
557 $updatesDone[] = $origParams;
558 $lbFactory->waitForReplication( [
'timeout' => self::REPLICATION_WAIT_TIMEOUT ] );
563 $this->updatesSkipped = array_merge( $this->updatesSkipped,
$updatesSkipped );
564 $this->updates = array_merge( $this->updates, $updatesDone );
575 $row = $this->db->selectRow(
579 [
'ul_key' => $key ],
601 $values = [
'ul_key' => $key ];
603 $values[
'ul_value'] = $val;
605 $this->db->insert(
'updatelog', $values, __METHOD__, [
'IGNORE' ] );
618 return $this->db->tableExists(
'updatelog', __METHOD__ ) &&
619 $this->db->fieldExists(
'updatelog',
'ul_value', __METHOD__ );
640 $this->
output(
"...skipping update to shared table $name.\n" );
657 global $wgExtNewFields, $wgExtNewTables, $wgExtModifiedFields,
662 foreach ( $wgExtNewTables as $tableRecord ) {
664 'addTable', $tableRecord[0], $tableRecord[1],
true
668 foreach ( $wgExtNewFields as $fieldRecord ) {
670 'addField', $fieldRecord[0], $fieldRecord[1],
671 $fieldRecord[2],
true
675 foreach ( $wgExtNewIndexes as $fieldRecord ) {
677 'addIndex', $fieldRecord[0], $fieldRecord[1],
678 $fieldRecord[2],
true
682 foreach ( $wgExtModifiedFields as $fieldRecord ) {
684 'modifyField', $fieldRecord[0], $fieldRecord[1],
685 $fieldRecord[2],
true
710 $this->db->sourceFile(
735 if ( fwrite( $this->fileHandle,
$line ) ===
false ) {
754 if ( $msg ===
null ) {
755 $msg =
"Applying $path patch";
757 if ( $this->skipSchema ) {
758 $this->
output(
"...skipping schema change ($msg).\n" );
763 $this->
output(
"$msg ..." );
765 if ( !$isFullPath ) {
768 if ( $this->fileHandle !==
null ) {
771 $this->db->sourceFile(
$path );
773 $this->
output(
"done.\n" );
791 if ( file_exists(
"$IP/maintenance/$dbType/archives/$patch" ) ) {
792 return "$IP/maintenance/$dbType/archives/$patch";
794 return "$IP/maintenance/archives/$patch";
809 protected function addTable( $name, $patch, $fullpath =
false ) {
810 if ( !$this->
doTable( $name ) ) {
814 if ( $this->db->tableExists( $name, __METHOD__ ) ) {
815 $this->
output(
"...$name table already exists.\n" );
817 return $this->
applyPatch( $patch, $fullpath,
"Creating $name table" );
835 protected function addField( $table, $field, $patch, $fullpath =
false ) {
836 if ( !$this->
doTable( $table ) ) {
840 if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
841 $this->
output(
"...$table table does not exist, skipping new field patch.\n" );
842 } elseif ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
843 $this->
output(
"...have $field field in $table table.\n" );
845 return $this->
applyPatch( $patch, $fullpath,
"Adding $field field to table $table" );
863 protected function addIndex( $table, $index, $patch, $fullpath =
false ) {
864 if ( !$this->
doTable( $table ) ) {
868 if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
869 $this->
output(
"...skipping: '$table' table doesn't exist yet.\n" );
870 } elseif ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
871 $this->
output(
"...index $index already set on $table table.\n" );
873 return $this->
applyPatch( $patch, $fullpath,
"Adding index $index to table $table" );
890 if ( !$this->
doTable( $table ) ) {
894 if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
895 $this->
output(
"...skipping: '$table' table doesn't exist yet.\n" );
899 $newIndex = $indexes[0];
900 foreach ( $indexes as $index ) {
901 if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
903 "...skipping index $newIndex because index $index already set on $table table.\n"
909 return $this->
applyPatch( $patch, $fullpath,
"Adding index $index to table $table" );
924 protected function dropField( $table, $field, $patch, $fullpath =
false ) {
925 if ( !$this->
doTable( $table ) ) {
929 if ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
930 return $this->
applyPatch( $patch, $fullpath,
"Table $table contains $field field. Dropping" );
932 $this->
output(
"...$table table does not contain $field field.\n" );
950 protected function dropIndex( $table, $index, $patch, $fullpath =
false ) {
951 if ( !$this->
doTable( $table ) ) {
955 if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
956 return $this->
applyPatch( $patch, $fullpath,
"Dropping $index index from table $table" );
958 $this->
output(
"...$index key doesn't exist.\n" );
981 $skipBothIndexExistWarning, $patch, $fullpath =
false
983 if ( !$this->
doTable( $table ) ) {
988 if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
989 $this->
output(
"...skipping: '$table' table doesn't exist yet.\n" );
995 if ( $this->db->indexExists( $table, $newIndex, __METHOD__ ) ) {
996 $this->
output(
"...index $newIndex already set on $table table.\n" );
997 if ( !$skipBothIndexExistWarning &&
998 $this->db->indexExists( $table, $oldIndex, __METHOD__ )
1000 $this->
output(
"...WARNING: $oldIndex still exists, despite it has " .
1001 "been renamed into $newIndex (which also exists).\n" .
1002 " $oldIndex should be manually removed if not needed anymore.\n" );
1009 if ( !$this->db->indexExists( $table, $oldIndex, __METHOD__ ) ) {
1010 $this->
output(
"...skipping: index $oldIndex doesn't exist.\n" );
1019 "Renaming index $oldIndex into $newIndex to table $table"
1037 protected function dropTable( $table, $patch =
false, $fullpath =
false ) {
1038 if ( !$this->
doTable( $table ) ) {
1042 if ( $this->db->tableExists( $table, __METHOD__ ) ) {
1043 $msg =
"Dropping table $table";
1045 if ( $patch ===
false ) {
1046 $this->
output(
"$msg ..." );
1047 $this->db->dropTable( $table, __METHOD__ );
1048 $this->
output(
"done.\n" );
1050 return $this->
applyPatch( $patch, $fullpath, $msg );
1053 $this->
output(
"...$table doesn't exist.\n" );
1073 protected function modifyField( $table, $field, $patch, $fullpath =
false ) {
1074 if ( !$this->
doTable( $table ) ) {
1078 $updateKey =
"$table-$field-$patch";
1079 if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
1080 $this->
output(
"...$table table does not exist, skipping modify field patch.\n" );
1081 } elseif ( !$this->db->fieldExists( $table, $field, __METHOD__ ) ) {
1082 $this->
output(
"...$field field does not exist in $table table, " .
1083 "skipping modify field patch.\n" );
1085 $this->
output(
"...$field in table $table already modified by patch $patch.\n" );
1087 $apply = $this->
applyPatch( $patch, $fullpath,
"Modifying $field field of table $table" );
1111 if ( !$this->
doTable( $table ) ) {
1115 $updateKey =
"$table-$patch";
1116 if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
1117 $this->
output(
"...$table table does not exist, skipping modify table patch.\n" );
1119 $this->
output(
"...table $table already modified by patch $patch.\n" );
1121 $apply = $this->
applyPatch( $patch, $fullpath,
"Modifying table $table" );
1151 $this->
output(
"Running $script...\n" );
1152 $task = $this->maintenance->runChild( $class );
1153 $ok = $task->execute();
1155 throw new RuntimeException(
"Execution of $script did not complete successfully." );
1157 $this->
output(
"done.\n" );
1166 $repo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
1167 $zonePath = $repo->getZonePath(
'temp' );
1168 if ( $repo->getBackend()->directoryExists( [
'dir' => $zonePath ] ) ) {
1170 $status = $repo->getBackend()->secure( [
1175 if ( $status->isOK() ) {
1176 $this->
output(
"Set the local repo temp zone container to be private.\n" );
1178 $this->
output(
"Failed to set the local repo temp zone container to be private.\n" );
1190 $this->
output(
"Purging caches..." );
1193 $this->db->delete(
'objectcache',
'*', __METHOD__ );
1201 $services = MediaWikiServices::getInstance();
1203 $services->getResourceLoader(),
1205 $services->getMainWANObjectCache()
1207 $blobStore->clear();
1210 $this->db->delete(
'module_deps',
'*', __METHOD__ );
1211 $this->
output(
"done.\n" );
1218 $this->
output(
"...site_stats is populated..." );
1219 $row = $this->db->selectRow(
'site_stats',
'*', [
'ss_row_id' => 1 ], __METHOD__ );
1220 if ( $row ===
false ) {
1221 $this->
output(
"data is missing! rebuilding...\n" );
1222 } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
1223 $this->
output(
"missing ss_total_pages, rebuilding...\n" );
1225 $this->
output(
"done.\n" );
1232 # Common updater functions
1238 $activeUsers = $this->db->selectField(
'site_stats',
'ss_active_users',
'', __METHOD__ );
1239 if ( $activeUsers == -1 ) {
1240 $activeUsers = $this->db->selectField(
'recentchanges',
1241 'COUNT( DISTINCT rc_user_text )',
1242 [
'rc_user != 0',
'rc_bot' => 0,
"rc_log_type != 'newusers'" ], __METHOD__
1244 $this->db->update(
'site_stats',
1245 [
'ss_active_users' => intval( $activeUsers ) ],
1246 [
'ss_row_id' => 1 ], __METHOD__, [
'LIMIT' => 1 ]
1249 $this->
output(
"...ss_active_users user count set...\n" );
1258 "Populating log_user_text field, printing progress markers. For large\n" .
1259 "databases, you may want to hit Ctrl-C and do this manually with\n" .
1260 "maintenance/populateLogUsertext.php.\n"
1263 $task = $this->maintenance->runChild( PopulateLogUsertext::class );
1265 $this->
output(
"done.\n" );
1275 "Populating log_search table, printing progress markers. For large\n" .
1276 "databases, you may want to hit Ctrl-C and do this manually with\n" .
1277 "maintenance/populateLogSearch.php.\n" );
1279 $task = $this->maintenance->runChild( PopulateLogSearch::class );
1281 $this->
output(
"done.\n" );
1290 if ( $this->db->fieldExists(
'categorylinks',
'cl_collation', __METHOD__ ) ) {
1291 if ( $this->db->selectField(
1298 $this->
output(
"...collations up-to-date.\n" );
1303 $this->
output(
"Updating category collations..." );
1304 $task = $this->maintenance->runChild( UpdateCollation::class );
1306 $this->
output(
"...done.\n" );
1314 if ( $this->db->tableExists(
'user_properties', __METHOD__ ) ) {
1315 $cl = $this->maintenance->runChild( ConvertUserOptions::class,
'convertUserOptions.php' );
1317 $this->
output(
"done.\n" );
1328 $cl = $this->maintenance->runChild(
1329 RebuildLocalisationCache::class,
'rebuildLocalisationCache.php'
1331 '@phan-var RebuildLocalisationCache $cl';
1332 $this->
output(
"Rebuilding localisation cache...\n" );
1335 $this->
output(
"done.\n" );
1345 "Migrating comments to the 'comments' table, printing progress markers. For large\n" .
1346 "databases, you may want to hit Ctrl-C and do this manually with\n" .
1347 "maintenance/migrateComments.php.\n"
1349 $task = $this->maintenance->runChild( MigrateComments::class,
'migrateComments.php' );
1350 $ok = $task->execute();
1351 $this->
output( $ok ?
"done.\n" :
"errors were encountered.\n" );
1360 if ( $this->
tableExists(
'image_comment_temp' ) ) {
1361 $this->
output(
"Merging image_comment_temp into the image table\n" );
1362 $task = $this->maintenance->runChild(
1363 MigrateImageCommentTemp::class,
'migrateImageCommentTemp.php'
1367 $ok = $task->execute();
1368 $this->
output( $ok ?
"done.\n" :
"errors were encountered.\n" );
1370 $this->
dropTable(
'image_comment_temp' );
1382 "Migrating actors to the 'actor' table, printing progress markers. For large\n" .
1383 "databases, you may want to hit Ctrl-C and do this manually with\n" .
1384 "maintenance/migrateActors.php.\n"
1386 $task = $this->maintenance->runChild(
'MigrateActors',
'migrateActors.php' );
1387 $ok = $task->execute();
1388 $this->
output( $ok ?
"done.\n" :
"errors were encountered.\n" );
1397 if ( $this->db->fieldExists(
'archive',
'ar_text', __METHOD__ ) ) {
1398 $this->
output(
"Migrating archive ar_text to modern storage.\n" );
1399 $task = $this->maintenance->runChild( MigrateArchiveText::class,
'migrateArchiveText.php' );
1402 if ( $task->execute() ) {
1403 $this->
applyPatch(
'patch-drop-ar_text.sql',
false,
1404 'Dropping ar_text and ar_flags columns' );
1414 $info = $this->db->fieldInfo(
'archive',
'ar_rev_id' );
1416 throw new MWException(
'Missing ar_rev_id field of archive table. Should not happen.' );
1418 if ( $info->isNullable() ) {
1419 $this->
output(
"Populating ar_rev_id.\n" );
1420 $task = $this->maintenance->runChild(
'PopulateArchiveRevId',
'populateArchiveRevId.php' );
1421 if ( $task->execute() ) {
1422 $this->
applyPatch(
'patch-ar_rev_id-not-null.sql',
false,
1423 'Making ar_rev_id not nullable' );
1433 if ( !$this->
updateRowExists(
'populate externallinks.el_index_60' ) ) {
1435 "Populating el_index_60 field, printing progress markers. For large\n" .
1436 "databases, you may want to hit Ctrl-C and do this manually with\n" .
1437 "maintenance/populateExternallinksIndex60.php.\n"
1439 $task = $this->maintenance->runChild(
'PopulateExternallinksIndex60',
1440 'populateExternallinksIndex60.php' );
1442 $this->
output(
"done.\n" );
1453 "Migrating revision data to the MCR 'slot' and 'content' tables, printing progress markers.\n" .
1454 "For large databases, you may want to hit Ctrl-C and do this manually with\n" .
1455 "maintenance/populateContentTables.php.\n"
1457 $task = $this->maintenance->runChild(
1458 PopulateContentTables::class,
'populateContentTables.php'
1460 $ok = $task->execute();
1461 $this->
output( $ok ?
"done.\n" :
"errors were encountered.\n" );
1492 if ( $table === $this ) {
1495 $func = array_shift( $params );
1498 if ( $this->db->tableExists( $table, __METHOD__ ) ) {
1502 if ( !is_array( $func ) && method_exists( $this, $func ) ) {
1503 $func = [ $this, $func ];
1504 } elseif ( $passSelf ) {
1505 array_unshift( $params, $this );
1509 return $func( ...$params );
1529 if ( $table === $this ) {
1533 $func = array_shift( $params );
1536 if ( !$this->db->tableExists( $table, __METHOD__ ) ||
1537 !$this->db->fieldExists( $table, $field, __METHOD__ )
1542 if ( !is_array( $func ) && method_exists( $this, $func ) ) {
1543 $func = [ $this, $func ];
1544 } elseif ( $passSelf ) {
1545 array_unshift( $params, $this );
1549 return $func( ...$params );
$wgAutoloadClasses
Array mapping class names to filenames, for autoloading.
$wgCategoryCollation
Specify how category names should be sorted, when listed on a category page.
$wgSharedDB
Shared database for multiple wikis.
$wgLocalisationCacheConf
Localisation cache configuration.
global $wgCommandLineMode
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Class for handling database updates.
purgeCache()
Purge various database caches.
addExtensionTable( $tableName, $sqlPath)
Convenience wrapper for addExtensionUpdate() when adding a new table (which is the most common usage ...
getDB()
Get a database connection to run updates.
setFileAccess()
Set any .htaccess files or equivilent for storage repos.
migrateImageCommentTemp()
Merge image_comment_temp into the image table.
loadExtensions()
Loads LocalSettings.php, if needed, and initialises everything needed for LoadExtensionSchemaUpdates ...
addIndex( $table, $index, $patch, $fullpath=false)
Add a new index to an existing table.
array $updates
Array of updates to perform on the database.
loadExtensionSchemaUpdates()
Cause extensions to register any updates they need to perform.
modifyExtensionTable( $tableName, $sqlPath)
Modify an existing extension table.
bool $skipSchema
Flag specifying whether or not to skip schema (e.g.
populateArchiveRevId()
Populate ar_rev_id, then make it not nullable.
runMaintenance( $class, $script)
Run a maintenance script.
migrateArchiveText()
Migrate ar_text to modern storage.
addField( $table, $field, $patch, $fullpath=false)
Add a new field to an existing table.
addExtensionIndex( $tableName, $indexName, $sqlPath)
Add an index to an existing extension table.
modifyTable( $table, $patch, $fullpath=false)
Modify an existing table, similar to modifyField.
doUpdates(array $what=[ 'core', 'extensions', 'stats'])
Do all the updates.
ifTableNotExists( $table, $func,... $params)
Only run a function if a table does not exist.
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
const REPLICATION_WAIT_TIMEOUT
runUpdates(array $updates, $passSelf)
Helper function for doUpdates()
getCoreUpdateList()
Get an array of updates to perform on the database.
populateExternallinksIndex60()
Populates the externallinks.el_index_60 field.
output( $str)
Output some text.
doLogSearchPopulation()
Migrate log params to new table and index for searching.
getPostDatabaseUpdateMaintenance()
doLogUsertextPopulation()
Populates the log_user_text field in the logging table.
getExtensionUpdates()
Get the list of extension-defined updates.
insertUpdateRow( $key, $val=null)
Helper function: Add a key to the updatelog table.
setAutoExtensionHookContainer(HookContainer $hookContainer)
Set the HookContainer to use for loading extension schema updates.
canUseNewUpdatelog()
Updatelog was changed in 1.17 to have a ul_value column so we can record more information about what ...
patchPath(IDatabase $db, $patch)
Get the full path of a patch file.
copyFile( $filename)
Append an SQL fragment to the open file handle.
string[] $postDatabaseUpdateMaintenance
Scripts to run after database update Should be a subclass of LoggedUpdateMaintenance.
HookContainer null $autoExtensionHookContainer
dropExtensionTable( $tableName, $sqlPath=false)
Drop an extension table.
renameIndex( $table, $oldIndex, $newIndex, $skipBothIndexExistWarning, $patch, $fullpath=false)
Rename an index from an existing table Stable to override.
writeSchemaUpdateFile(array $schemaUpdate=[])
rebuildLocalisationCache()
Rebuilds the localisation cache.
addExtensionField( $tableName, $columnName, $sqlPath)
Add a field to an existing extension table.
IMaintainableDatabase $db
Handle to the database subclass.
ifFieldExists( $table, $field, $func,... $params)
Only run a function if the named field exists.
addTable( $name, $patch, $fullpath=false)
Add a new table to the database.
modifyField( $table, $field, $patch, $fullpath=false)
Modify an existing field.
doActiveUsersInit()
Sets the number of active users in the site_stats table.
addIndexIfNoneExist( $table, $indexes, $patch, $fullpath=false)
Add a new index to an existing table if none of the given indexes exist.
dropExtensionField( $tableName, $columnName, $sqlPath)
Drop a field from an extension table.
static newForDB(IMaintainableDatabase $db, $shared=false, Maintenance $maintenance=null)
getOldGlobalUpdates()
Before 1.17, we used to handle updates via stuff like $wgExtNewTables/Fields/Indexes.
addPostDatabaseUpdateMaintenance( $class)
Add a maintenance script to be run after the database updates are complete.
dropField( $table, $field, $patch, $fullpath=false)
Drop a field from an existing table.
doCollationUpdate()
Update CategoryLinks collation.
renameExtensionIndex( $tableName, $oldIndexName, $newIndexName, $sqlPath, $skipBothIndexExistWarning=false)
Rename an index on an extension table Intended for use in LoadExtensionSchemaUpdates hook handlers.
migrateActors()
Migrate actors to the new 'actor' table.
addExtensionUpdate(array $update)
Add a new update coming from an extension.
array $updatesSkipped
Array of updates that were skipped.
resource $fileHandle
File handle for SQL output.
appendLine( $line)
Append a line to the open filehandle.
dropExtensionIndex( $tableName, $indexName, $sqlPath)
Drop an index from an extension table Intended for use in LoadExtensionSchemaUpdates hook handlers.
initOldGlobals()
Initialize all of the old globals.
array $extensionUpdates
List of extension-provided database updates.
checkStats()
Check the site_stats table is not properly populated.
modifyExtensionField( $tableName, $fieldName, $sqlPath)
Modify an existing field in an extension table.
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
dropIndex( $table, $index, $patch, $fullpath=false)
Drop an index from an existing table.
populateContentTables()
Populates the MCR content tables.
__construct(IMaintainableDatabase &$db, $shared, Maintenance $maintenance=null)
Stable to call.
dropTable( $table, $patch=false, $fullpath=false)
If the specified table exists, drop it, or execute the patch if one is provided.
migrateComments()
Migrate comments to the new 'comment' table.
ifNoActorTable( $func,... $params)
getSchemaVars()
Get appropriate schema variables in the current database connection.
doTable( $name)
Returns whether updates should be executed on the database table $name.
doMigrateUserOptions()
Migrates user options from the user table blob to user_properties.
Fake maintenance wrapper, mostly used for the web installer/updater.
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
static getDBTypes()
Get a list of known DB types.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
setDB(IMaintainableDatabase $db)
Sets database object to be returned by getDB().
This class generates message blobs for use by ResourceLoader.
static doAllAndCommit( $database, array $options=[])
Do all updates and commit them.
Advanced database interface for IDatabase handles that include maintenance methods.