r49679 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49678‎ | r49679 | r49680 >
Date:22:43, 20 April 2009
Author:greg
Status:ok
Tags:
Comment:
Add $wgExtPGAlteredFields
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updaters.inc
@@ -176,7 +176,8 @@
177177 # $wgDBtype should be checked to specifiy the proper file
178178 $wgExtNewTables = array(); // table, dir
179179 $wgExtNewFields = array(); // table, column, dir
180 -$wgExtPGNewFields = array(); // table, column attributes; for PostgreSQL
 180+$wgExtPGNewFields = array(); // table, column, column attributes; for PostgreSQL
 181+$wgExtPGAlteredFields = array(); // table, column, new type, conversion method; for PostgreSQL
181182 $wgExtNewIndexes = array(); // table, index, dir
182183
183184 # Helper function: check if the given key is present in the updatelog table.
@@ -1807,7 +1808,7 @@
18081809 dbsource(archive('patch-ipb_address_unique.sql'));
18091810 }
18101811
1811 - global $wgExtNewTables, $wgExtPGNewFields, $wgExtNewIndexes;
 1812+ global $wgExtNewTables, $wgExtPGNewFields, $wgExtPGAlteredFields, $wgExtNewIndexes;
18121813 # Add missing extension tables
18131814 foreach ( $wgExtNewTables as $nt ) {
18141815 if ($wgDatabase->tableExists($nt[0])) {
@@ -1827,6 +1828,26 @@
18281829 wfOut( "Adding column \"$nc[0].$nc[1]\"\n" );
18291830 $wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" );
18301831 }
 1832+ # Change altered columns
 1833+ foreach ( $wgExtPGAlteredFields as $nc ) {
 1834+ $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]);
 1835+ if (is_null($fi)) {
 1836+ wfOut( "WARNING! Column \"$nc[0].$nc[1]\" does not exist but had an alter request! Please report this.\n" );
 1837+ continue;
 1838+ }
 1839+ $oldtype = $fi->type();
 1840+ $newtype = strtolower( $nc[2] );
 1841+ if ($oldtype === $newtype) {
 1842+ wfOut( "... column \"$nc[0].$nc[1]\" has correct type of \"$newtype\"\n" );
 1843+ continue;
 1844+ }
 1845+ $command = "ALTER TABLE $nc[0] ALTER $nc[1] TYPE $nc[2]";
 1846+ if ( isset( $nc[3] ) ) {
 1847+ $command .= " USING $nc[3]";
 1848+ }
 1849+ wfOut( "Altering column \"$nc[0].$nc[1]\" from type \"$oldtype\" to \"$newtype\"\n" );
 1850+ $wgDatabase->query( $command );
 1851+ }
18311852 # Add missing extension indexes
18321853 foreach ( $wgExtNewIndexes as $ni ) {
18331854 if (pg_index_exists($ni[0], $ni[1])) {
Index: trunk/phase3/RELEASE-NOTES
@@ -169,7 +169,10 @@
170170 {{REVISIONTIMESTAMP}} (and friends) and {{REVISIONUSER}} magic words
171171 * (bug 18529) New hook: SoftwareInfo for adding information about the software
172172 to Special:Version
 173+* Added $wgExtPGAlteredFields to allow extensions to easily alter the data
 174+ type of columns when using the Postgres backend.
173175
 176+
174177 === Bug fixes in 1.15 ===
175178 * (bug 16968) Special:Upload no longer throws useless warnings.
176179 * (bug 17000) Special:RevisionDelete now checks if the database is locked

Status & tagging log