X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Finstaller%2FPostgresUpdater.php;h=84d33b8e28286671bf16802c6c629d204e90de23;hp=c829d51cfcce0736b08716578a9bb31ee04136d2;hb=f1f96285b0aa5dae9dc3e394055baa82f7b4700f;hpb=621d00d59bf589d17cf3fa1d18fe55ad5aa91812 diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index c829d51cfc..84d33b8e28 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -481,6 +481,11 @@ class PostgresUpdater extends DatabaseUpdater { [ 'changeNullableField', 'protected_titles', 'pt_reason', 'NOT NULL', true ], [ 'addPgField', 'protected_titles', 'pt_reason_id', 'INTEGER NOT NULL DEFAULT 0' ], [ 'addTable', 'comment', 'patch-comment-table.sql' ], + [ 'addTable', 'revision_comment_temp', 'patch-revision_comment_temp-table.sql' ], + // image_comment_temp is no longer needed when upgrading to MW 1.31 or newer, + // as it is dropped later in the update process as part of 'migrateImageCommentTemp'. + // File kept on disk and the updater entry here for historical purposes. + // [ 'addTable', 'image_comment_temp', 'patch-image_comment_temp-table.sql' ], // This field was added in 1.31, but is put here so it can be used by 'migrateComments' [ 'addPgField', 'image', 'img_description_id', 'INTEGER NOT NULL DEFAULT 0' ], @@ -539,6 +544,36 @@ class PostgresUpdater extends DatabaseUpdater { [ 'migrateActors' ], [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ], [ 'populateArchiveRevId' ], + [ 'dropPgIndex', 'recentchanges', 'rc_namespace_title' ], + [ + 'addPgIndex', + 'recentchanges', + 'rc_namespace_title_timestamp', '( rc_namespace, rc_title, rc_timestamp )' + ], + [ 'setSequenceOwner', 'mwuser', 'user_id', 'user_user_id_seq' ], + [ 'setSequenceOwner', 'actor', 'actor_id', 'actor_actor_id_seq' ], + [ 'setSequenceOwner', 'page', 'page_id', 'page_page_id_seq' ], + [ 'setSequenceOwner', 'revision', 'rev_id', 'revision_rev_id_seq' ], + [ 'setSequenceOwner', 'ip_changes', 'ipc_rev_id', 'ip_changes_ipc_rev_id_seq' ], + [ 'setSequenceOwner', 'pagecontent', 'old_id', 'text_old_id_seq' ], + [ 'setSequenceOwner', 'comment', 'comment_id', 'comment_comment_id_seq' ], + [ 'setSequenceOwner', 'page_restrictions', 'pr_id', 'page_restrictions_pr_id_seq' ], + [ 'setSequenceOwner', 'archive', 'ar_id', 'archive_ar_id_seq' ], + [ 'setSequenceOwner', 'content', 'content_id', 'content_content_id_seq' ], + [ 'setSequenceOwner', 'slot_roles', 'role_id', 'slot_roles_role_id_seq' ], + [ 'setSequenceOwner', 'content_models', 'model_id', 'content_models_model_id_seq' ], + [ 'setSequenceOwner', 'externallinks', 'el_id', 'externallinks_el_id_seq' ], + [ 'setSequenceOwner', 'ipblocks', 'ipb_id', 'ipblocks_ipb_id_seq' ], + [ 'setSequenceOwner', 'filearchive', 'fa_id', 'filearchive_fa_id_seq' ], + [ 'setSequenceOwner', 'uploadstash', 'us_id', 'uploadstash_us_id_seq' ], + [ 'setSequenceOwner', 'recentchanges', 'rc_id', 'recentchanges_rc_id_seq' ], + [ 'setSequenceOwner', 'watchlist', 'wl_id', 'watchlist_wl_id_seq' ], + [ 'setSequenceOwner', 'logging', 'log_id', 'logging_log_id_seq' ], + [ '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' ], ]; } @@ -706,9 +741,11 @@ END; protected function addSequence( $table, $pkey, $ns ) { if ( !$this->db->sequenceExists( $ns ) ) { $this->output( "Creating sequence $ns\n" ); - $this->db->query( "CREATE SEQUENCE $ns" ); if ( $pkey !== false ) { + $this->db->query( "CREATE SEQUENCE $ns OWNED BY $table.$pkey" ); $this->setDefault( $table, $pkey, '"nextval"(\'"' . $ns . '"\'::"regclass")' ); + } else { + $this->db->query( "CREATE SEQUENCE $ns" ); } } } @@ -732,6 +769,13 @@ END; } } + protected function setSequenceOwner( $table, $pkey, $seq ) { + if ( $this->db->sequenceExists( $seq ) ) { + $this->output( "Setting sequence $seq owner to $table.$pkey\n" ); + $this->db->query( "ALTER SEQUENCE $seq OWNED BY $table.$pkey" ); + } + } + protected function renameTable( $old, $new, $patch = false ) { if ( $this->db->tableExists( $old ) ) { $this->output( "Renaming table $old to $new\n" );