Add updatelog table to reliably permit updates that don't change the schema. A fairl...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 18 Mar 2008 00:06:06 +0000 (00:06 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 18 Mar 2008 00:06:06 +0000 (00:06 +0000)
RELEASE-NOTES
maintenance/archives/patch-updatelog.sql [new file with mode: 0644]
maintenance/tables.sql
maintenance/updaters.inc

index d4511bf..5e22643 100644 (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 ===
 
diff --git a/maintenance/archives/patch-updatelog.sql b/maintenance/archives/patch-updatelog.sql
new file mode 100644 (file)
index 0000000..168ad08
--- /dev/null
@@ -0,0 +1,4 @@
+CREATE TABLE /*$wgDBprefix*/updatelog (
+  ul_key varchar(255) NOT NULL,
+  PRIMARY KEY (ul_key)
+) /*$wgDBTableOptions*/;
index 13a29de..135c28e 100644 (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
index 7e0991b..a1498e9 100644 (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