Merge "Simplify and unify the {{REVISIONID}} handling code in Parser"
[lhc/web/wiklou.git] / includes / installer / PostgresUpdater.php
index 917f589..008240a 100644 (file)
@@ -71,7 +71,6 @@ class PostgresUpdater extends DatabaseUpdater {
                        [ 'addSequence', 'externallinks', false, 'externallinks_el_id_seq' ],
                        [ 'addSequence', 'watchlist', false, 'watchlist_wl_id_seq' ],
                        [ 'addSequence', 'change_tag', false, 'change_tag_ct_id_seq' ],
-                       [ 'addSequence', 'tag_summary', false, 'tag_summary_ts_id_seq' ],
 
                        # new tables
                        [ 'addTable', 'category', 'patch-category.sql' ],
@@ -84,8 +83,6 @@ class PostgresUpdater extends DatabaseUpdater {
                        [ 'addTable', 'redirect', 'patch-redirect.sql' ],
                        [ 'addTable', 'updatelog', 'patch-updatelog.sql' ],
                        [ 'addTable', 'change_tag', 'patch-change_tag.sql' ],
-                       [ 'addTable', 'tag_summary', 'patch-tag_summary.sql' ],
-                       [ 'addTable', 'valid_tag', 'patch-valid_tag.sql' ],
                        [ 'addTable', 'user_properties', 'patch-user_properties.sql' ],
                        [ 'addTable', 'log_search', 'patch-log_search.sql' ],
                        [ 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ],
@@ -443,8 +440,6 @@ class PostgresUpdater extends DatabaseUpdater {
                                '( rc_namespace, rc_type, rc_patrolled, rc_timestamp )' ],
                        [ 'addPgField', 'change_tag', 'ct_id',
                                "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('change_tag_ct_id_seq')" ],
-                       [ 'addPgField', 'tag_summary', 'ts_id',
-                               "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('tag_summary_ts_id_seq')" ],
 
                        // 1.29
                        [ 'addPgField', 'externallinks', 'el_index_60', "BYTEA NOT NULL DEFAULT ''" ],
@@ -567,7 +562,6 @@ class PostgresUpdater extends DatabaseUpdater {
                        [ 'setSequenceOwner', 'job', 'job_id', 'job_job_id_seq' ],
                        [ 'setSequenceOwner', 'category', 'cat_id', 'category_cat_id_seq' ],
                        [ 'setSequenceOwner', 'change_tag', 'ct_id', 'change_tag_ct_id_seq' ],
-                       [ 'setSequenceOwner', 'tag_summary', 'ts_id', 'tag_summary_ts_id_seq' ],
                        [ 'setSequenceOwner', 'sites', 'site_id', 'sites_site_id_seq' ],
 
                        // 1.32
@@ -598,9 +592,32 @@ class PostgresUpdater extends DatabaseUpdater {
                        [ 'addPgField', 'ipblocks', 'ipb_sitewide', 'SMALLINT NOT NULL DEFAULT 1' ],
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
+                       [ 'dropPgField', 'category', 'cat_hidden' ],
+                       [ 'dropPgField', 'site_stats', 'ss_admins' ],
+                       [ 'dropPgField', 'recentchanges', 'rc_cur_time' ],
 
                        // 1.33
                        [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
+                       [ 'dropTable', 'valid_tag' ],
+                       [ 'dropTable', 'tag_summary' ],
+                       [ 'dropPgField', 'archive', 'ar_comment' ],
+                       [ 'dropDefault', 'archive', 'ar_comment_id' ],
+                       [ 'dropPgField', 'ipblocks', 'ipb_reason' ],
+                       [ 'dropDefault', 'ipblocks', 'ipb_reason_id' ],
+                       [ 'dropPgField', 'image', 'img_description' ],
+                       [ 'dropDefault', 'image', 'img_description_id' ],
+                       [ 'dropPgField', 'oldimage', 'oi_description' ],
+                       [ 'dropDefault', 'oldimage', 'oi_description_id' ],
+                       [ 'dropPgField', 'filearchive', 'fa_deleted_reason' ],
+                       [ 'dropDefault', 'filearchive', 'fa_deleted_reason_id' ],
+                       [ 'dropPgField', 'filearchive', 'fa_description' ],
+                       [ 'dropDefault', 'filearchive', 'fa_description_id' ],
+                       [ 'dropPgField', 'recentchanges', 'rc_comment' ],
+                       [ 'dropDefault', 'recentchanges', 'rc_comment_id' ],
+                       [ 'dropPgField', 'logging', 'log_comment' ],
+                       [ 'dropDefault', 'logging', 'log_comment_id' ],
+                       [ 'dropPgField', 'protected_titles', 'pt_reason' ],
+                       [ 'dropDefault', 'protected_titles', 'pt_reason_id' ],
                ];
        }
 
@@ -822,7 +839,7 @@ END;
                if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
                        $this->output( "...skipping: '$table' table doesn't exist yet.\n" );
 
-                       return;
+                       return true;
                }
 
                // Second requirement: the new index must be missing
@@ -836,17 +853,18 @@ END;
                                        "            $old should be manually removed if not needed anymore.\n" );
                        }
 
-                       return;
+                       return true;
                }
 
                // Third requirement: the old index must exist
                if ( !$this->db->indexExists( $table, $old, __METHOD__ ) ) {
                        $this->output( "...skipping: index $old doesn't exist.\n" );
 
-                       return;
+                       return true;
                }
 
                $this->db->query( "ALTER INDEX $old RENAME TO $new" );
+               return true;
        }
 
        protected function dropPgField( $table, $field ) {
@@ -929,7 +947,7 @@ END;
 
        protected function setDefault( $table, $field, $default ) {
                $info = $this->db->fieldInfo( $table, $field );
-               if ( $info->defaultValue() !== $default ) {
+               if ( $info && $info->defaultValue() !== $default ) {
                        $this->output( "Changing '$table.$field' default value\n" );
                        $this->db->query( "ALTER TABLE $table ALTER $field SET DEFAULT "
                                . $this->db->addQuotes( $default ) );
@@ -953,8 +971,7 @@ END;
        protected function changeNullableField( $table, $field, $null, $update = false ) {
                $fi = $this->db->fieldInfo( $table, $field );
                if ( is_null( $fi ) ) {
-                       $this->output( "...ERROR: expected column $table.$field to exist\n" );
-                       exit( 1 );
+                       return;
                }
                if ( $fi->isNullable() ) {
                        # # It's NULL - does it need to be NOT NULL?
@@ -991,13 +1008,11 @@ END;
        public function addPgExtIndex( $table, $index, $type ) {
                if ( $this->db->indexExists( $table, $index ) ) {
                        $this->output( "...index '$index' on table '$table' already exists\n" );
+               } elseif ( preg_match( '/^\(/', $type ) ) {
+                       $this->output( "Creating index '$index' on table '$table'\n" );
+                       $this->db->query( "CREATE INDEX $index ON $table $type" );
                } else {
-                       if ( preg_match( '/^\(/', $type ) ) {
-                               $this->output( "Creating index '$index' on table '$table'\n" );
-                               $this->db->query( "CREATE INDEX $index ON $table $type" );
-                       } else {
-                               $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" );
-                       }
+                       $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" );
                }
        }