diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-08-12 09:28:15 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-08-12 09:28:15 +0200 |
commit | 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch) | |
tree | 577a29fb579188d16003a209ce2a2e9c5b0aa2bd /includes/installer/PostgresUpdater.php | |
parent | cacc939b34e315b85e2d72997811eb6677996cc1 (diff) |
Update to MediaWiki 1.21.1
Diffstat (limited to 'includes/installer/PostgresUpdater.php')
-rw-r--r-- | includes/installer/PostgresUpdater.php | 96 |
1 files changed, 68 insertions, 28 deletions
diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 6cffe84a..0a4b5e65 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -90,6 +90,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ), array( 'addTable', 'user_former_groups','patch-user_former_groups.sql' ), array( 'addTable', 'external_user', 'patch-external_user.sql' ), + array( 'addTable', 'sites', 'patch-sites.sql' ), # Needed before new field array( 'convertArchive2' ), @@ -100,6 +101,8 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgField', 'archive', 'ar_len', 'INTEGER' ), array( 'addPgField', 'archive', 'ar_page_id', 'INTEGER' ), array( 'addPgField', 'archive', 'ar_parent_id', 'INTEGER' ), + array( 'addPgField', 'archive', 'ar_content_model', 'TEXT' ), + array( 'addPgField', 'archive', 'ar_content_format', 'TEXT' ), array( 'addPgField', 'categorylinks', 'cl_sortkey_prefix', "TEXT NOT NULL DEFAULT ''"), array( 'addPgField', 'categorylinks', 'cl_collation', "TEXT NOT NULL DEFAULT 0"), array( 'addPgField', 'categorylinks', 'cl_type', "TEXT NOT NULL DEFAULT 'page'"), @@ -113,6 +116,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgField', 'ipblocks', 'ipb_enable_autoblock', 'SMALLINT NOT NULL DEFAULT 1' ), array( 'addPgField', 'ipblocks', 'ipb_parent_block_id', 'INTEGER DEFAULT NULL REFERENCES ipblocks(ipb_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED' ), array( 'addPgField', 'filearchive', 'fa_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), + array( 'addPgField', 'filearchive', 'fa_sha1', "TEXT NOT NULL DEFAULT ''" ), array( 'addPgField', 'logging', 'log_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), array( 'addPgField', 'logging', 'log_id', "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('logging_log_id_seq')" ), array( 'addPgField', 'logging', 'log_params', 'TEXT' ), @@ -124,6 +128,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgField', 'oldimage', 'oi_metadata', "BYTEA NOT NULL DEFAULT ''" ), array( 'addPgField', 'oldimage', 'oi_minor_mime', "TEXT NOT NULL DEFAULT 'unknown'" ), array( 'addPgField', 'oldimage', 'oi_sha1', "TEXT NOT NULL DEFAULT ''" ), + array( 'addPgField', 'page', 'page_content_model', 'TEXT' ), array( 'addPgField', 'page_restrictions', 'pr_id', "INTEGER NOT NULL UNIQUE DEFAULT nextval('page_restrictions_pr_id_seq')" ), array( 'addPgField', 'profiling', 'pf_memory', 'NUMERIC(18,10) NOT NULL DEFAULT 0' ), array( 'addPgField', 'recentchanges', 'rc_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), @@ -138,6 +143,8 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgField', 'revision', 'rev_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), array( 'addPgField', 'revision', 'rev_len', 'INTEGER' ), array( 'addPgField', 'revision', 'rev_parent_id', 'INTEGER DEFAULT NULL' ), + array( 'addPgField', 'revision', 'rev_content_model', 'TEXT' ), + array( 'addPgField', 'revision', 'rev_content_format', 'TEXT' ), array( 'addPgField', 'site_stats', 'ss_active_users', "INTEGER DEFAULT '-1'" ), array( 'addPgField', 'user_newtalk', 'user_last_timestamp', 'TIMESTAMPTZ' ), array( 'addPgField', 'logging', 'log_user_text', "TEXT NOT NULL DEFAULT ''" ), @@ -148,6 +155,11 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgField', 'archive', 'ar_sha1', "TEXT NOT NULL DEFAULT ''" ), array( 'addPgField', 'uploadstash', 'us_chunk_inx', "INTEGER NULL" ), array( 'addPgField', 'job', 'job_timestamp', "TIMESTAMPTZ" ), + array( 'addPgField', 'job', 'job_random', "INTEGER NOT NULL DEFAULT 0" ), + array( 'addPgField', 'job', 'job_attempts', "INTEGER NOT NULL DEFAULT 0" ), + array( 'addPgField', 'job', 'job_token', "TEXT NOT NULL DEFAULT ''" ), + array( 'addPgField', 'job', 'job_token_timestamp', "TIMESTAMPTZ" ), + array( 'addPgField', 'job', 'job_sha1', "TEXT NOT NULL DEFAULT ''" ), # type changes array( 'changeField', 'archive', 'ar_deleted', 'smallint', '' ), @@ -213,6 +225,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgIndex', 'oldimage', 'oi_sha1', '(oi_sha1)' ), array( 'addPgIndex', 'page', 'page_mediawiki_title', '(page_title) WHERE page_namespace = 8' ), array( 'addPgIndex', 'pagelinks', 'pagelinks_title', '(pl_title)' ), + array( 'addPgIndex', 'page_props', 'pp_propname_page', '(pp_propname, pp_page)' ), array( 'addPgIndex', 'revision', 'rev_text_id_idx', '(rev_text_id)' ), array( 'addPgIndex', 'recentchanges', 'rc_timestamp_bot', '(rc_timestamp) WHERE rc_bot = 0' ), array( 'addPgIndex', 'templatelinks', 'templatelinks_from', '(tl_from)' ), @@ -221,64 +234,68 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgIndex', 'logging', 'logging_page_id_time', '(log_page,log_timestamp)' ), array( 'addPgIndex', 'iwlinks', 'iwl_prefix_title_from', '(iwl_prefix, iwl_title, iwl_from)' ), array( 'addPgIndex', 'job', 'job_timestamp_idx', '(job_timestamp)' ), + array( 'addPgIndex', 'job', 'job_sha1', '(job_sha1)' ), + array( 'addPgIndex', 'job', 'job_cmd_token', '(job_cmd, job_token, job_random)' ), + array( 'addPgIndex', 'job', 'job_cmd_token_id', '(job_cmd, job_token, job_id)' ), + array( 'addPgIndex', 'filearchive', 'fa_sha1', '(fa_sha1)' ), array( 'checkIndex', 'pagelink_unique', array( - array('pl_from', 'int4_ops', 'btree', 0), - array('pl_namespace', 'int2_ops', 'btree', 0), - array('pl_title', 'text_ops', 'btree', 0), + array( 'pl_from', 'int4_ops', 'btree', 0 ), + array( 'pl_namespace', 'int2_ops', 'btree', 0 ), + array( 'pl_title', 'text_ops', 'btree', 0 ), ), 'CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)' ), array( 'checkIndex', 'cl_sortkey', array( - array('cl_to', 'text_ops', 'btree', 0), - array('cl_sortkey', 'text_ops', 'btree', 0), - array('cl_from', 'int4_ops', 'btree', 0), + array( 'cl_to', 'text_ops', 'btree', 0 ), + array( 'cl_sortkey', 'text_ops', 'btree', 0 ), + array( 'cl_from', 'int4_ops', 'btree', 0 ), ), 'CREATE INDEX cl_sortkey ON "categorylinks" USING "btree" ("cl_to", "cl_sortkey", "cl_from")' ), array( 'checkIndex', 'logging_times', array( - array('log_timestamp', 'timestamptz_ops', 'btree', 0), + array( 'log_timestamp', 'timestamptz_ops', 'btree', 0 ), ), 'CREATE INDEX "logging_times" ON "logging" USING "btree" ("log_timestamp")' ), array( 'dropIndex', 'oldimage', 'oi_name' ), array( 'checkIndex', 'oi_name_archive_name', array( - array('oi_name', 'text_ops', 'btree', 0), - array('oi_archive_name', 'text_ops', 'btree', 0), + array( 'oi_name', 'text_ops', 'btree', 0 ), + array( 'oi_archive_name', 'text_ops', 'btree', 0 ), ), 'CREATE INDEX "oi_name_archive_name" ON "oldimage" USING "btree" ("oi_name", "oi_archive_name")' ), array( 'checkIndex', 'oi_name_timestamp', array( - array('oi_name', 'text_ops', 'btree', 0), - array('oi_timestamp', 'timestamptz_ops', 'btree', 0), + array( 'oi_name', 'text_ops', 'btree', 0 ), + array( 'oi_timestamp', 'timestamptz_ops', 'btree', 0 ), ), 'CREATE INDEX "oi_name_timestamp" ON "oldimage" USING "btree" ("oi_name", "oi_timestamp")' ), array( 'checkIndex', 'page_main_title', array( - array('page_title', 'text_pattern_ops', 'btree', 0), + array( 'page_title', 'text_pattern_ops', 'btree', 0 ), ), 'CREATE INDEX "page_main_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 0)' ), array( 'checkIndex', 'page_mediawiki_title', array( - array('page_title', 'text_pattern_ops', 'btree', 0), + array( 'page_title', 'text_pattern_ops', 'btree', 0 ), ), 'CREATE INDEX "page_mediawiki_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 8)' ), array( 'checkIndex', 'page_project_title', array( - array('page_title', 'text_pattern_ops', 'btree', 0), + array( 'page_title', 'text_pattern_ops', 'btree', 0 ), ), 'CREATE INDEX "page_project_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 4)' ), array( 'checkIndex', 'page_talk_title', array( - array('page_title', 'text_pattern_ops', 'btree', 0), + array( 'page_title', 'text_pattern_ops', 'btree', 0 ), ), 'CREATE INDEX "page_talk_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 1)' ), array( 'checkIndex', 'page_user_title', array( - array('page_title', 'text_pattern_ops', 'btree', 0), + array( 'page_title', 'text_pattern_ops', 'btree', 0 ), ), 'CREATE INDEX "page_user_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 2)' ), array( 'checkIndex', 'page_utalk_title', array( - array('page_title', 'text_pattern_ops', 'btree', 0), + array( 'page_title', 'text_pattern_ops', 'btree', 0 ), ), 'CREATE INDEX "page_utalk_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 3)' ), array( 'checkIndex', 'ts2_page_text', array( - array('textvector', 'tsvector_ops', 'gist', 0), + array( 'textvector', 'tsvector_ops', 'gist', 0 ), ), 'CREATE INDEX "ts2_page_text" ON "pagecontent" USING "gist" ("textvector")' ), array( 'checkIndex', 'ts2_page_title', array( - array('titlevector', 'tsvector_ops', 'gist', 0), + array( 'titlevector', 'tsvector_ops', 'gist', 0 ), ), 'CREATE INDEX "ts2_page_title" ON "page" USING "gist" ("titlevector")' ), @@ -287,10 +304,10 @@ class PostgresUpdater extends DatabaseUpdater { array( 'checkRevUserFkey' ), array( 'dropIndex', 'ipblocks', 'ipb_address'), array( 'checkIndex', 'ipb_address_unique', array( - array('ipb_address', 'text_ops', 'btree', 0), - array('ipb_user', 'int4_ops', 'btree', 0), - array('ipb_auto', 'int2_ops', 'btree', 0), - array('ipb_anon_only', 'int2_ops', 'btree', 0), + array( 'ipb_address', 'text_ops', 'btree', 0 ), + array( 'ipb_user', 'int4_ops', 'btree', 0 ), + array( 'ipb_auto', 'int2_ops', 'btree', 0 ), + array( 'ipb_anon_only', 'int2_ops', 'btree', 0 ), ), 'CREATE UNIQUE INDEX ipb_address_unique ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only)' ), @@ -493,7 +510,7 @@ END; $this->output( "Creating sequence $ns\n" ); $this->db->query( "CREATE SEQUENCE $ns" ); if( $pkey !== false ) { - $this->setDefault( $table, $pkey, '"nextval"(\'"' . $ns . '"\'::"regclass")' ); + $this->setDefault( $table, $pkey, '"nextval"(\'"' . $ns . '"\'::"regclass")' ); } } } @@ -521,11 +538,34 @@ END; } } - protected function renameIndex( $table, $old, $new ) { - if ( $this->db->indexExists( $table, $old ) ) { - $this->output( "Renaming index $old to $new\n" ); - $this->db->query( "ALTER INDEX $old RENAME TO $new" ); + protected function renameIndex( + $table, $old, $new, $skipBothIndexExistWarning = false, $a = false, $b = false + ) { + // First requirement: the table must exist + if ( !$this->db->tableExists( $table, __METHOD__ ) ) { + $this->output( "...skipping: '$table' table doesn't exist yet.\n" ); + return; + } + + // Second requirement: the new index must be missing + if ( $this->db->indexExists( $table, $new, __METHOD__ ) ) { + $this->output( "...index $new already set on $table table.\n" ); + if ( !$skipBothIndexExistWarning + && $this->db->indexExists( $table, $old, __METHOD__ ) ) + { + $this->output( "...WARNING: $old still exists, despite it has been renamed into $new (which also exists).\n" . + " $old should be manually removed if not needed anymore.\n" ); + } + return; } + + // Third requirement: the old index must exist + if ( !$this->db->indexExists( $table, $old, __METHOD__ ) ) { + $this->output( "...skipping: index $old doesn't exist.\n" ); + return; + } + + $this->db->query( "ALTER INDEX $old RENAME TO $new" ); } protected function addPgField( $table, $field, $type ) { |