From 5a9878f32d491ecd561045595e8d4f9bfeefc257 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 11 Aug 2007 14:43:47 +0000 Subject: [PATCH] Fixups for page id field in the archive table: * Make the field nullable for consistency with ar_rev_id and ar_text_id and between MySQL and PostgreSQL and generally so you can cleanly tell between bogus fields and ones that predate use of the field * Remove duplicate incorrect adding of the field for postgres * Rename to ar_page_id for consistency with ar_rev_id and ar_text_id * Rename the patch file for naming consistency Note that there's no documentation of this schema change in the release notes either, which bugs me a bit. --- includes/Article.php | 2 +- ...archive-ar_page.sql => patch-archive-page_id.sql} | 12 ++++++------ maintenance/postgres/tables.sql | 2 +- maintenance/tables.sql | 7 +++++-- maintenance/updaters.inc | 5 ++--- 5 files changed, 15 insertions(+), 13 deletions(-) rename maintenance/archives/{patch-archive-ar_page.sql => patch-archive-page_id.sql} (78%) diff --git a/includes/Article.php b/includes/Article.php index 086e68cdb0..56feb72eef 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -2114,7 +2114,7 @@ class Article { 'ar_text' => '\'\'', // Be explicit to appease 'ar_flags' => '\'\'', // MySQL's "strict mode"... 'ar_len' => 'rev_len', - 'ar_page' => $id + 'ar_page_id' => 'page_id', ), array( 'page_id' => $id, 'page_id = rev_page' diff --git a/maintenance/archives/patch-archive-ar_page.sql b/maintenance/archives/patch-archive-page_id.sql similarity index 78% rename from maintenance/archives/patch-archive-ar_page.sql rename to maintenance/archives/patch-archive-page_id.sql index 4ea98cf5a2..47a1c47e41 100644 --- a/maintenance/archives/patch-archive-ar_page.sql +++ b/maintenance/archives/patch-archive-page_id.sql @@ -1,6 +1,6 @@ --- Reference to page_id. Useful for sysadmin fixing of large --- pages merged together in the archives --- Added 2007-07-21 - -ALTER TABLE /*$wgDBprefix*/archive - ADD ar_page int unsigned NOT NULL; +-- Reference to page_id. Useful for sysadmin fixing of large +-- pages merged together in the archives +-- Added 2007-07-21 + +ALTER TABLE /*$wgDBprefix*/archive + ADD ar_page_id int unsigned; diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index 30ea077711..6f91efaff5 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -128,7 +128,7 @@ CREATE TABLE archive ( ar_namespace SMALLINT NOT NULL, ar_title TEXT NOT NULL, ar_text TEXT, - ar_page INTEGER NULL, + ar_page_id INTEGER NULL, ar_comment TEXT, ar_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL, ar_user_text TEXT NOT NULL, diff --git a/maintenance/tables.sql b/maintenance/tables.sql index d76e5a85fa..08119cd25d 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -378,8 +378,11 @@ CREATE TABLE /*$wgDBprefix*/archive ( ar_len int unsigned, -- Reference to page_id. Useful for sysadmin fixing of large pages - -- merged together in the archives - ar_page int unsigned NOT NULL, + -- merged together in the archives, or for cleanly restoring a page + -- at its original ID number if possible. + -- + -- Will be NULL for pages deleted prior to 1.11. + ar_page_id int unsigned, KEY name_title_timestamp (ar_namespace,ar_title,ar_timestamp), KEY usertext_timestamp (ar_user_text,ar_timestamp) diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index 407da309a2..e8fd2061f2 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -81,7 +81,7 @@ $wgNewFields = array( array( 'page_restrictions', 'pr_id', 'patch-page_restrictions_sortkey.sql' ), array( 'ipblocks', 'ipb_block_email', 'patch-ipb_emailban.sql' ), array( 'oldimage', 'oi_metadata', 'patch-oi_metadata.sql'), - array( 'archive', 'ar_page', 'patch-archive-ar_page.sql'), + array( 'archive', 'ar_page_id', 'patch-archive-page_id.sql'), array( 'image', 'img_sha1', 'patch-img_sha1.sql' ), ); @@ -1319,7 +1319,7 @@ function do_postgres_updates() { $newcols = array( array("archive", "ar_len", "INTEGER"), - array("archive", "ar_page", "INTEGER"), + array("archive", "ar_page_id", "INTEGER"), array("image", "img_sha1", "TEXT NOT NULL DEFAULT ''"), array("ipblocks", "ipb_anon_only", "CHAR NOT NULL DEFAULT '0'"), array("ipblocks", "ipb_block_email", "CHAR NOT NULL DEFAULT '0'"), @@ -1347,7 +1347,6 @@ function do_postgres_updates() { array("recentchanges", "rc_old_len", "INTEGER"), array("recentchanges", "rc_params", "TEXT"), array("revision", "rev_len", "INTEGER"), - array("archive", "ar_page", "INTEGER NOT NULL DEFAULT 0"), ); -- 2.20.1