diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
commit | c9aa36da061816dee256a979c2ff8d2ee41824d9 (patch) | |
tree | 29f7002b80ee984b488bd047dbbd80b36bf892e9 /includes/installer/PostgresUpdater.php | |
parent | b4274e0e33eafb5e9ead9d949ebf031a9fb8363b (diff) | |
parent | d1ba966140d7a60cd5ae4e8667ceb27c1a138592 (diff) |
Merge branch 'archwiki'
# Conflicts:
# skins/ArchLinux.php
# skins/ArchLinux/archlogo.gif
Diffstat (limited to 'includes/installer/PostgresUpdater.php')
-rw-r--r-- | includes/installer/PostgresUpdater.php | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 304c5466..9e8ee94f 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -27,7 +27,6 @@ * @ingroup Deployment * @since 1.17 */ - class PostgresUpdater extends DatabaseUpdater { /** @@ -235,6 +234,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'changeNullableField', 'image', 'img_metadata', 'NOT NULL' ), array( 'changeNullableField', 'filearchive', 'fa_metadata', 'NOT NULL' ), array( 'changeNullableField', 'recentchanges', 'rc_cur_id', 'NULL' ), + array( 'changeNullableField', 'recentchanges', 'rc_cur_time', 'NULL' ), array( 'checkOiDeleted' ), @@ -250,6 +250,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgIndex', 'recentchanges', 'rc_timestamp_bot', '(rc_timestamp) WHERE rc_bot = 0' ), array( 'addPgIndex', 'templatelinks', 'templatelinks_from', '(tl_from)' ), array( 'addPgIndex', 'watchlist', 'wl_user', '(wl_user)' ), + array( 'addPgIndex', 'watchlist', 'wl_user_notificationtimestamp', '(wl_user, wl_notificationtimestamp)' ), array( 'addPgIndex', 'logging', 'logging_user_type_time', '(log_user, log_type, log_timestamp)' ), array( 'addPgIndex', 'logging', 'logging_page_id_time', '(log_page,log_timestamp)' ), @@ -260,6 +261,9 @@ class PostgresUpdater extends DatabaseUpdater { 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( 'addPgIndex', 'logging', 'logging_user_text_type_time', + '(log_user_text, log_type, log_timestamp)' ), + array( 'addPgIndex', 'logging', 'logging_user_text_time', '(log_user_text, log_timestamp)' ), array( 'checkIndex', 'pagelink_unique', array( array( 'pl_from', 'int4_ops', 'btree', 0 ), @@ -398,6 +402,22 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addInterwikiType' ), # end array( 'tsearchFixes' ), + + // 1.23 + array( 'addPgField', 'recentchanges', 'rc_source', "TEXT NOT NULL DEFAULT ''" ), + array( 'addPgField', 'page', 'page_links_updated', "TIMESTAMPTZ NULL" ), + array( 'addPgField', 'mwuser', 'user_password_expires', 'TIMESTAMPTZ NULL' ), + array( 'changeFieldPurgeTable', 'l10n_cache', 'lc_value', 'bytea', + "replace(lc_value,'\','\\\\')::bytea" ), + + // 1.24 + array( 'addPgField', 'page_props', 'pp_sortkey', 'float NULL' ), + array( 'addPgIndex', 'page_props', 'pp_propname_sortkey_page', + '( pp_propname, pp_sortkey, pp_page ) WHERE ( pp_sortkey IS NOT NULL )' ), + array( 'addPgField', 'page', 'page_lang', 'TEXT default NULL' ), + array( 'addPgField', 'pagelinks', 'pl_from_namespace', 'INTEGER NOT NULL DEFAULT 0' ), + array( 'addPgField', 'templatelinks', 'tl_from_namespace', 'INTEGER NOT NULL DEFAULT 0' ), + array( 'addPgField', 'imagelinks', 'il_from_namespace', 'INTEGER NOT NULL DEFAULT 0' ), ); } @@ -664,6 +684,35 @@ END; } } + protected function changeFieldPurgeTable( $table, $field, $newtype, $default ) { + ## For a cache table, empty it if the field needs to be changed, because the old contents + ## may be corrupted. If the column is already the desired type, refrain from purging. + $fi = $this->db->fieldInfo( $table, $field ); + if ( is_null( $fi ) ) { + $this->output( "...ERROR: expected column $table.$field to exist\n" ); + exit( 1 ); + } + + if ( $fi->type() === $newtype ) { + $this->output( "...column '$table.$field' is already of type '$newtype'\n" ); + } else { + $this->output( "Purging data from cache table '$table'\n" ); + $this->db->query( "DELETE from $table" ); + $this->output( "Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" ); + $sql = "ALTER TABLE $table ALTER $field TYPE $newtype"; + if ( strlen( $default ) ) { + $res = array(); + if ( preg_match( '/DEFAULT (.+)/', $default, $res ) ) { + $sqldef = "ALTER TABLE $table ALTER $field SET DEFAULT $res[1]"; + $this->db->query( $sqldef ); + $default = preg_replace( '/\s*DEFAULT .+/', '', $default ); + } + $sql .= " USING $default"; + } + $this->db->query( $sql ); + } + } + protected function setDefault( $table, $field, $default ) { $info = $this->db->fieldInfo( $table, $field ); |