From b7bf2dd85055ceed9bf6ea19dd6760f0811b6dc7 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 18 Mar 2008 00:06:06 +0000 Subject: [PATCH] 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. --- RELEASE-NOTES | 1 + maintenance/archives/patch-updatelog.sql | 4 ++++ maintenance/tables.sql | 6 ++++++ maintenance/updaters.inc | 16 +++++++++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 maintenance/archives/patch-updatelog.sql diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d4511bf995..5e226435d5 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/maintenance/archives/patch-updatelog.sql b/maintenance/archives/patch-updatelog.sql new file mode 100644 index 0000000000..168ad082eb --- /dev/null +++ b/maintenance/archives/patch-updatelog.sql @@ -0,0 +1,4 @@ +CREATE TABLE /*$wgDBprefix*/updatelog ( + ul_key varchar(255) NOT NULL, + PRIMARY KEY (ul_key) +) /*$wgDBTableOptions*/; diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 13a29dedbb..135c28e27d 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -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 diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index 7e0991bb9e..a1498e9145 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -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 -- 2.20.1