MediaWiki  master
PostgresUpdater Class Reference

Class for handling updates to Postgres databases. More...

Inheritance diagram for PostgresUpdater:
Collaboration diagram for PostgresUpdater:

Protected Member Functions

 addInterwikiType ()
 
 addPgEnumValue ( $type, $value)
 Add a value to an existing PostgreSQL enum type. More...
 
 addPgExtIndex ( $table, $index, $type)
 
 addPgField ( $table, $field, $type)
 
 addPgIndex ( $table, $index, $type, $unique=false)
 
 addSequence ( $table, $pkey, $ns)
 
 changeField ( $table, $field, $newtype, $default)
 
 changeFieldPurgeTable ( $table, $field, $newtype, $default)
 
 changeFkeyDeferrable ( $table, $field, $clause)
 
 changeNullableField ( $table, $field, $null, $update=false)
 
 checkIndex ( $index, $should_be, $good_def)
 
 checkIwlPrefix ()
 
 checkOiDeleted ()
 
 checkOiNameConstraint ()
 
 checkPageDeletedTrigger ()
 
 checkRevUserFkey ()
 
 convertArchive2 ()
 
 describeIndex ( $idx)
 
 describeTable ( $table)
 
 dropDefault ( $table, $field)
 Drop a default value from a field. More...
 
 dropFkey ( $table, $field)
 
 dropPgField ( $table, $field)
 
 dropPgIndex ( $table, $index)
 
 dropSequence ( $table, $ns)
 
 fkeyDeltype ( $fkey)
 
 getCoreUpdateList ()
 
 getOldGlobalUpdates ()
 Before 1.17, we used to handle updates via stuff like $wgExtNewTables/Fields/Indexes. More...
 
 rebuildTextSearch ()
 
 renameIndex ( $table, $old, $new, $skipBothIndexExistWarning=false, $a=false, $b=false)
 Rename an index from an existing table Stable to override. More...
 
 renameSequence ( $old, $new)
 
 renameTable ( $old, $new, $patch=false)
 
 ruleDef ( $table, $rule)
 
 setDefault ( $table, $field, $default)
 
 setSequenceOwner ( $table, $pkey, $seq)
 
 tsearchFixes ()
 
- Protected Member Functions inherited from DatabaseUpdater
 __construct (IMaintainableDatabase &$db, $shared, Maintenance $maintenance=null)
 Stable to call. More...
 
 addField ( $table, $field, $patch, $fullpath=false)
 Add a new field to an existing table. More...
 
 addIndex ( $table, $index, $patch, $fullpath=false)
 Add a new index to an existing table. More...
 
 addIndexIfNoneExist ( $table, $indexes, $patch, $fullpath=false)
 Add a new index to an existing table if none of the given indexes exist. More...
 
 addTable ( $name, $patch, $fullpath=false)
 Add a new table to the database. More...
 
 appendLine ( $line)
 Append a line to the open filehandle. More...
 
 applyPatch ( $path, $isFullPath=false, $msg=null)
 Applies a SQL patch. More...
 
 canUseNewUpdatelog ()
 Updatelog was changed in 1.17 to have a ul_value column so we can record more information about what kind of updates we've done (that's what this class does). More...
 
 checkStats ()
 Check the site_stats table is not properly populated. More...
 
 copyFile ( $filename)
 Append an SQL fragment to the open file handle. More...
 
 doActiveUsersInit ()
 Sets the number of active users in the site_stats table. More...
 
 doCollationUpdate ()
 Update CategoryLinks collation. More...
 
 doLogSearchPopulation ()
 Migrate log params to new table and index for searching. More...
 
 doLogUsertextPopulation ()
 Populates the log_user_text field in the logging table. More...
 
 doMigrateUserOptions ()
 Migrates user options from the user table blob to user_properties. More...
 
 doTable ( $name)
 Returns whether updates should be executed on the database table $name. More...
 
 dropField ( $table, $field, $patch, $fullpath=false)
 Drop a field from an existing table. More...
 
 dropIndex ( $table, $index, $patch, $fullpath=false)
 Drop an index from an existing table. More...
 
 dropTable ( $table, $patch=false, $fullpath=false)
 If the specified table exists, drop it, or execute the patch if one is provided. More...
 
 getExtensionUpdates ()
 Get the list of extension-defined updates. More...
 
 ifFieldExists ( $table, $field, $func,... $params)
 Only run a function if the named field exists. More...
 
 ifNoActorTable ( $func,... $params)
 
 ifTableNotExists ( $table, $func,... $params)
 Only run a function if a table does not exist. More...
 
 migrateActors ()
 Migrate actors to the new 'actor' table. More...
 
 migrateArchiveText ()
 Migrate ar_text to modern storage. More...
 
 migrateComments ()
 Migrate comments to the new 'comment' table. More...
 
 migrateImageCommentTemp ()
 Merge image_comment_temp into the image table. More...
 
 modifyField ( $table, $field, $patch, $fullpath=false)
 Modify an existing field. More...
 
 modifyTable ( $table, $patch, $fullpath=false)
 Modify an existing table, similar to modifyField. More...
 
 populateArchiveRevId ()
 Populate ar_rev_id, then make it not nullable. More...
 
 populateContentTables ()
 Populates the MCR content tables. More...
 
 populateExternallinksIndex60 ()
 Populates the externallinks.el_index_60 field. More...
 
 rebuildLocalisationCache ()
 Rebuilds the localisation cache. More...
 
 runMaintenance ( $class, $script)
 Run a maintenance script. More...
 

Protected Attributes

DatabasePostgres $db
 
- Protected Attributes inherited from DatabaseUpdater
IMaintainableDatabase $db
 Handle to the database subclass. More...
 
array $extensionUpdates = []
 List of extension-provided database updates. More...
 
resource $fileHandle = null
 File handle for SQL output. More...
 
Maintenance $maintenance
 
string[] $postDatabaseUpdateMaintenance
 Scripts to run after database update Should be a subclass of LoggedUpdateMaintenance. More...
 
 $shared = false
 
bool $skipSchema = false
 Flag specifying whether or not to skip schema (e.g. More...
 
array $updates = []
 Array of updates to perform on the database. More...
 
array $updatesSkipped = []
 Array of updates that were skipped. More...
 

Additional Inherited Members

- Public Member Functions inherited from DatabaseUpdater
 addExtensionField ( $tableName, $columnName, $sqlPath)
 Add a field to an existing extension table. More...
 
 addExtensionIndex ( $tableName, $indexName, $sqlPath)
 Add an index to an existing extension table. More...
 
 addExtensionTable ( $tableName, $sqlPath)
 Convenience wrapper for addExtensionUpdate() when adding a new table (which is the most common usage of updaters in an extension) Intended for use in LoadExtensionSchemaUpdates hook handlers. More...
 
 addExtensionUpdate (array $update)
 Add a new update coming from an extension. More...
 
 addPostDatabaseUpdateMaintenance ( $class)
 Add a maintenance script to be run after the database updates are complete. More...
 
 doUpdates (array $what=[ 'core', 'extensions', 'stats'])
 Do all the updates. More...
 
 dropExtensionField ( $tableName, $columnName, $sqlPath)
 Drop a field from an extension table. More...
 
 dropExtensionIndex ( $tableName, $indexName, $sqlPath)
 Drop an index from an extension table Intended for use in LoadExtensionSchemaUpdates hook handlers. More...
 
 dropExtensionTable ( $tableName, $sqlPath=false)
 Drop an extension table. More...
 
 getDB ()
 Get a database connection to run updates. More...
 
 getPostDatabaseUpdateMaintenance ()
 
 getSchemaVars ()
 Get appropriate schema variables in the current database connection. More...
 
 insertUpdateRow ( $key, $val=null)
 Helper function: Add a key to the updatelog table. More...
 
 modifyExtensionField ( $tableName, $fieldName, $sqlPath)
 Modify an existing field in an extension table. More...
 
 modifyExtensionTable ( $tableName, $sqlPath)
 Modify an existing extension table. More...
 
 output ( $str)
 Output some text. More...
 
 patchPath (IDatabase $db, $patch)
 Get the full path of a patch file. More...
 
 purgeCache ()
 Purge various database caches. More...
 
 renameExtensionIndex ( $tableName, $oldIndexName, $newIndexName, $sqlPath, $skipBothIndexExistWarning=false)
 Rename an index on an extension table Intended for use in LoadExtensionSchemaUpdates hook handlers. More...
 
 setFileAccess ()
 Set any .htaccess files or equivilent for storage repos. More...
 
 tableExists ( $tableName)
 
 updateRowExists ( $key)
 Helper function: check if the given key is present in the updatelog table. More...
 
- Static Public Member Functions inherited from DatabaseUpdater
static newForDB (IMaintainableDatabase $db, $shared=false, Maintenance $maintenance=null)
 
- Public Attributes inherited from DatabaseUpdater
const REPLICATION_WAIT_TIMEOUT = 300
 

Detailed Description

Class for handling updates to Postgres databases.

Since
1.17

Definition at line 32 of file PostgresUpdater.php.

Member Function Documentation

◆ addInterwikiType()

PostgresUpdater::addInterwikiType ( )
protected

Definition at line 1320 of file PostgresUpdater.php.

References DatabaseUpdater\applyPatch().

◆ addPgEnumValue()

PostgresUpdater::addPgEnumValue (   $type,
  $value 
)
protected

Add a value to an existing PostgreSQL enum type.

Since
1.31
Parameters
string$typeType name. Must be in the core schema.
string$valueValue to add.

Definition at line 1126 of file PostgresUpdater.php.

References $type, and DatabaseUpdater\output().

◆ addPgExtIndex()

PostgresUpdater::addPgExtIndex (   $table,
  $index,
  $type 
)
protected

◆ addPgField()

PostgresUpdater::addPgField (   $table,
  $field,
  $type 
)
protected

Definition at line 983 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ addPgIndex()

PostgresUpdater::addPgIndex (   $table,
  $index,
  $type,
  $unique = false 
)
protected

Definition at line 1099 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ addSequence()

PostgresUpdater::addSequence (   $table,
  $pkey,
  $ns 
)
protected

Definition at line 886 of file PostgresUpdater.php.

References DatabaseUpdater\output(), and setDefault().

◆ changeField()

PostgresUpdater::changeField (   $table,
  $field,
  $newtype,
  $default 
)
protected

Definition at line 995 of file PostgresUpdater.php.

References $res, and DatabaseUpdater\output().

◆ changeFieldPurgeTable()

PostgresUpdater::changeFieldPurgeTable (   $table,
  $field,
  $newtype,
  $default 
)
protected

Definition at line 1020 of file PostgresUpdater.php.

References $res, and DatabaseUpdater\output().

◆ changeFkeyDeferrable()

PostgresUpdater::changeFkeyDeferrable (   $table,
  $field,
  $clause 
)
protected

Definition at line 1178 of file PostgresUpdater.php.

References $command, and DatabaseUpdater\output().

◆ changeNullableField()

PostgresUpdater::changeNullableField (   $table,
  $field,
  $null,
  $update = false 
)
protected

Definition at line 1072 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ checkIndex()

PostgresUpdater::checkIndex (   $index,
  $should_be,
  $good_def 
)
protected

Definition at line 1278 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ checkIwlPrefix()

PostgresUpdater::checkIwlPrefix ( )
protected

Definition at line 1310 of file PostgresUpdater.php.

References DatabaseUpdater\applyPatch().

◆ checkOiDeleted()

PostgresUpdater::checkOiDeleted ( )
protected

Definition at line 1226 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ checkOiNameConstraint()

PostgresUpdater::checkOiNameConstraint ( )
protected

Definition at line 1238 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ checkPageDeletedTrigger()

PostgresUpdater::checkPageDeletedTrigger ( )
protected

Definition at line 1259 of file PostgresUpdater.php.

References DatabaseUpdater\applyPatch(), and DatabaseUpdater\output().

◆ checkRevUserFkey()

PostgresUpdater::checkRevUserFkey ( )
protected

◆ convertArchive2()

PostgresUpdater::convertArchive2 ( )
protected

Definition at line 1206 of file PostgresUpdater.php.

References DatabaseUpdater\applyPatch(), and DatabaseUpdater\output().

◆ describeIndex()

PostgresUpdater::describeIndex (   $idx)
protected

Definition at line 786 of file PostgresUpdater.php.

References $res.

◆ describeTable()

PostgresUpdater::describeTable (   $table)
protected

Definition at line 757 of file PostgresUpdater.php.

References $res.

◆ dropDefault()

PostgresUpdater::dropDefault (   $table,
  $field 
)
protected

Drop a default value from a field.

Since
1.32
Parameters
string$table
string$field

Definition at line 1064 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ dropFkey()

PostgresUpdater::dropFkey (   $table,
  $field 
)
protected

Definition at line 1160 of file PostgresUpdater.php.

References $command, and DatabaseUpdater\output().

◆ dropPgField()

PostgresUpdater::dropPgField (   $table,
  $field 
)
protected

Definition at line 971 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ dropPgIndex()

PostgresUpdater::dropPgIndex (   $table,
  $index 
)
protected

Definition at line 1271 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ dropSequence()

PostgresUpdater::dropSequence (   $table,
  $ns 
)
protected

Definition at line 898 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ fkeyDeltype()

PostgresUpdater::fkeyDeltype (   $fkey)
protected

Definition at line 838 of file PostgresUpdater.php.

Referenced by checkRevUserFkey().

◆ getCoreUpdateList()

PostgresUpdater::getCoreUpdateList ( )
protected
Todo:
FIXME: Postgres should use sequential updates like Mysql, Sqlite and everybody else.

It never got refactored like it should've.

Returns
array

Reimplemented from DatabaseUpdater.

Definition at line 44 of file PostgresUpdater.php.

References true.

◆ getOldGlobalUpdates()

PostgresUpdater::getOldGlobalUpdates ( )
protected

Before 1.17, we used to handle updates via stuff like $wgExtNewTables/Fields/Indexes.

This is nasty :) We refactored a lot of this in 1.17 but we want to remain back-compatible for a while. So load up these old global-based things into our update list.

Stable to override

Returns
array

Reimplemented from DatabaseUpdater.

Definition at line 718 of file PostgresUpdater.php.

References DatabaseUpdater\$updates, and true.

◆ rebuildTextSearch()

PostgresUpdater::rebuildTextSearch ( )
protected

◆ renameIndex()

PostgresUpdater::renameIndex (   $table,
  $oldIndex,
  $newIndex,
  $skipBothIndexExistWarning = false,
  $patch = false,
  $fullpath = false 
)
protected

Rename an index from an existing table Stable to override.

Note
Code in a LoadExtensionSchemaUpdates handler should use renameExtensionIndex instead!
Parameters
string$tableName of the table to modify
string$oldIndexOld name of the index
string$newIndexNew name of the index
bool$skipBothIndexExistWarningWhether to warn if both the old and the new indexes exist.
string$patchPath to the patch file
bool$fullpathWhether to treat $patch path as a relative or not
Returns
bool False if this was skipped because schema changes are skipped

Reimplemented from DatabaseUpdater.

Definition at line 936 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ renameSequence()

PostgresUpdater::renameSequence (   $old,
  $new 
)
protected

Definition at line 905 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ renameTable()

PostgresUpdater::renameTable (   $old,
  $new,
  $patch = false 
)
protected

Definition at line 924 of file PostgresUpdater.php.

References DatabaseUpdater\applyPatch(), and DatabaseUpdater\output().

◆ ruleDef()

PostgresUpdater::ruleDef (   $table,
  $rule 
)
protected

Definition at line 861 of file PostgresUpdater.php.

◆ setDefault()

PostgresUpdater::setDefault (   $table,
  $field,
  $default 
)
protected

Definition at line 1049 of file PostgresUpdater.php.

References DatabaseUpdater\output().

Referenced by addSequence().

◆ setSequenceOwner()

PostgresUpdater::setSequenceOwner (   $table,
  $pkey,
  $seq 
)
protected

Definition at line 917 of file PostgresUpdater.php.

References DatabaseUpdater\output().

◆ tsearchFixes()

PostgresUpdater::tsearchFixes ( )
protected

Definition at line 1324 of file PostgresUpdater.php.

References DatabaseUpdater\applyPatch().

Member Data Documentation

◆ $db

DatabasePostgres PostgresUpdater::$db
protected

Definition at line 37 of file PostgresUpdater.php.


The documentation for this class was generated from the following file: