array( 'add_table', 'categorylinks', 'patch-categorylinks.sql' ),
// do_linkscc_1_3_update obsolete
array( 'do_old_links_update' ),
+ array( 'fix_ancient_imagelinks' ),
array( 'add_field', 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ),
// 1.4
array( 'add_table', 'change_tag', 'patch-change_tag.sql' ),
array( 'add_table', 'tag_summary', 'patch-change_tag.sql' ),
array( 'add_table', 'valid_tag', 'patch-change_tag.sql' ),
+ array( 'add_table', 'user_properties', 'patch-user_properties.sql' ),
+ array( 'add_table', 'log_search', 'patch-log_search.sql' ),
+ array( 'do_log_search_population' ),
),
'sqlite' => array(
array( 'add_table', 'change_tag', 'patch-change_tag.sql' ),
array( 'add_table', 'tag_summary', 'patch-change_tag.sql' ),
array( 'add_table', 'valid_tag', 'patch-change_tag.sql' ),
+ array( 'add_table', 'user_properties', 'patch-user_properties.sql' ),
+ array( 'add_table', 'log_search', 'patch-log_search.sql' ),
+ array( 'do_log_search_population' ),
),
);
# $wgDBtype should be checked to specifiy the proper file
$wgExtNewTables = array(); // table, dir
$wgExtNewFields = array(); // table, column, dir
-$wgExtPGNewFields = array(); // table, column attributes; for PostgreSQL
+$wgExtPGNewFields = array(); // table, column, column attributes; for PostgreSQL
+$wgExtPGAlteredFields = array(); // table, column, new type, conversion method; for PostgreSQL
$wgExtNewIndexes = array(); // table, index, dir
# Helper function: check if the given key is present in the updatelog table.
}
}
+function fix_ancient_imagelinks() {
+ global $wgDatabase;
+ $info = $wgDatabase->fieldInfo( 'imagelinks', 'il_from' );
+ if ( $info && $info->type() === 'string' ) {
+ wfOut( "Fixing ancient broken imagelinks table.\n" );
+ wfOut( "NOTE: you will have to run maintenance/refreshLinks.php after this.\n" );
+ dbsource( archive( 'patch-fix-il_from.sql' ) );
+ wfOut( "ok\n" );
+ } else {
+ wfOut( "...il_from OK\n" );
+ }
+}
+
function do_user_unique_update() {
global $wgDatabase;
$duper = new UserDupes( $wgDatabase );
}
}
+function do_log_search_population() {
+ global $wgDatabase;
+ if( update_row_exists( 'populate log_search' ) ) {
+ wfOut( "...log_search table already populated.\n" );
+ return;
+ }
+ require_once( 'populateLogSearch.inc' );
+ wfOut(
+"Populating log_search table, printing progress markers. For large\n" .
+"databases, you may want to hit Ctrl-C and do this manually with\n" .
+"maintenance/populateLogSearch.php.\n" );
+ migrate_log_params( $wgDatabase );
+ wfOut( "Done populating log_search table.\n" );
+}
+
/***********************************************************************
* Start PG crap
* TODO: merge with above
array("redirect", "patch-redirect.sql"),
array("updatelog", "patch-updatelog.sql"),
array('change_tag', 'patch-change_tag.sql'),
- array('tag_summary', 'patch-change_tag.sql'),
- array('valid_tag', 'patch-change_tag.sql'),
+ array('tag_summary', 'patch-change_tag.sql'),
+ array('valid_tag', 'patch-change_tag.sql'),
+ array('user_properties', 'patch-user_properties.sql'),
+ array('log_search', 'patch-log_search.sql'),
);
$newcols = array(
dbsource(archive('patch-ipb_address_unique.sql'));
}
- global $wgExtNewTables, $wgExtPGNewFields, $wgExtNewIndexes;
+ global $wgExtNewTables, $wgExtPGNewFields, $wgExtPGAlteredFields, $wgExtNewIndexes;
# Add missing extension tables
foreach ( $wgExtNewTables as $nt ) {
if ($wgDatabase->tableExists($nt[0])) {
wfOut( "Adding column \"$nc[0].$nc[1]\"\n" );
$wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" );
}
+ # Change altered columns
+ foreach ( $wgExtPGAlteredFields as $nc ) {
+ $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]);
+ if (is_null($fi)) {
+ wfOut( "WARNING! Column \"$nc[0].$nc[1]\" does not exist but had an alter request! Please report this.\n" );
+ continue;
+ }
+ $oldtype = $fi->type();
+ $newtype = strtolower( $nc[2] );
+ if ($oldtype === $newtype) {
+ wfOut( "... column \"$nc[0].$nc[1]\" has correct type of \"$newtype\"\n" );
+ continue;
+ }
+ $command = "ALTER TABLE $nc[0] ALTER $nc[1] TYPE $nc[2]";
+ if ( isset( $nc[3] ) ) {
+ $command .= " USING $nc[3]";
+ }
+ wfOut( "Altering column \"$nc[0].$nc[1]\" from type \"$oldtype\" to \"$newtype\"\n" );
+ $wgDatabase->query( $command );
+ }
# Add missing extension indexes
foreach ( $wgExtNewIndexes as $ni ) {
if (pg_index_exists($ni[0], $ni[1])) {
continue;
}
wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\"\n" );
- dbsource($ni[2]);
+ if ( preg_match( '/^\(/', $ni[2] ) ) {
+ $wgDatabase->query( "CREATE INDEX $ni[1] ON $ni[0] $ni[2]" );
+ }
+ else {
+ dbsource($ni[2]);
+ }
}
# Tweak the page_title tsearch2 trigger to filter out slashes