Add updatelog table to reliably permit updates that don't change the schema. A fairly trivial patch. It isn't used at all currently (it will be in a minute!), and presumably won't ever be used outside of update.php, so it can be ignored for Wikimedia despite being a schema change.

This commit is contained in:
Aryeh Gregor 2008-03-18 00:06:06 +00:00
parent 62d77f2640
commit b7bf2dd850
4 changed files with 26 additions and 1 deletions

View file

@ -45,6 +45,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
* (bug 12882) Added a span with class "patrollink" arround "Mark as patrolled"
link on diffs
* Magic word formatnum can now take raw suffix to undo formatting
* Add updatelog table to reliably permit updates that don't change the schema
=== Bug fixes in 1.13 ===

View file

@ -0,0 +1,4 @@
CREATE TABLE /*$wgDBprefix*/updatelog (
ul_key varchar(255) NOT NULL,
PRIMARY KEY (ul_key)
) /*$wgDBTableOptions*/;

View file

@ -1193,4 +1193,10 @@ CREATE TABLE /*$wgDBprefix*/page_props (
PRIMARY KEY (pp_page,pp_propname)
) /*$wgDBTableOptions*/;
-- A table to log updates, one text key row per update.
CREATE TABLE /*$wgDBprefix*/updatelog (
ul_key varchar(255) NOT NULL,
PRIMARY KEY (ul_key)
) /*$wgDBTableOptions*/;
-- vim: sw=2 sts=2 et

View file

@ -132,6 +132,7 @@ $wgMysqlUpdates = array(
// 1.13
array( 'add_field', 'ipblocks', 'ipb_by_text', 'patch-ipb_by_text.sql' ),
array( 'add_table', 'page_props', 'patch-page_props.sql' ),
array( 'add_table', 'updatelog', 'patch-updatelog.sql' ),
);
@ -142,6 +143,20 @@ $wgExtNewFields = array(); // table, column, dir
$wgExtPGNewFields = array(); // table, column attributes; for PostgreSQL
$wgExtNewIndexes = array(); // table, index, dir
# Helper function: check if the given key is present in the updatelog table.
# Obviously, only use this for updates that occur after the updatelog table was
# created!
function update_row_exists( $key ) {
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow(
'updatelog',
'1',
array( 'ul_key' => $key ),
__FUNCTION__
);
return (bool)$row;
}
function rename_table( $from, $to, $patch ) {
global $wgDatabase;
if ( $wgDatabase->tableExists( $from ) ) {
@ -1118,7 +1133,6 @@ function do_restrictions_update() {
}
print "ok\n";
}
}
function