Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -176,7 +176,8 @@ |
177 | 177 | # $wgDBtype should be checked to specifiy the proper file |
178 | 178 | $wgExtNewTables = array(); // table, dir |
179 | 179 | $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 |
181 | 182 | $wgExtNewIndexes = array(); // table, index, dir |
182 | 183 | |
183 | 184 | # Helper function: check if the given key is present in the updatelog table. |
— | — | @@ -1807,7 +1808,7 @@ |
1808 | 1809 | dbsource(archive('patch-ipb_address_unique.sql')); |
1809 | 1810 | } |
1810 | 1811 | |
1811 | | - global $wgExtNewTables, $wgExtPGNewFields, $wgExtNewIndexes; |
| 1812 | + global $wgExtNewTables, $wgExtPGNewFields, $wgExtPGAlteredFields, $wgExtNewIndexes; |
1812 | 1813 | # Add missing extension tables |
1813 | 1814 | foreach ( $wgExtNewTables as $nt ) { |
1814 | 1815 | if ($wgDatabase->tableExists($nt[0])) { |
— | — | @@ -1827,6 +1828,26 @@ |
1828 | 1829 | wfOut( "Adding column \"$nc[0].$nc[1]\"\n" ); |
1829 | 1830 | $wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" ); |
1830 | 1831 | } |
| 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 | + } |
1831 | 1852 | # Add missing extension indexes |
1832 | 1853 | foreach ( $wgExtNewIndexes as $ni ) { |
1833 | 1854 | if (pg_index_exists($ni[0], $ni[1])) { |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -169,7 +169,10 @@ |
170 | 170 | {{REVISIONTIMESTAMP}} (and friends) and {{REVISIONUSER}} magic words |
171 | 171 | * (bug 18529) New hook: SoftwareInfo for adding information about the software |
172 | 172 | to Special:Version |
| 173 | +* Added $wgExtPGAlteredFields to allow extensions to easily alter the data |
| 174 | + type of columns when using the Postgres backend. |
173 | 175 | |
| 176 | + |
174 | 177 | === Bug fixes in 1.15 === |
175 | 178 | * (bug 16968) Special:Upload no longer throws useless warnings. |
176 | 179 | * (bug 17000) Special:RevisionDelete now checks if the database is locked |