From: MusikAnimal Date: Mon, 13 Nov 2017 18:52:55 +0000 (-0500) Subject: Add SQL for postgres, and fail gracefully in populateIpChanges X-Git-Tag: 1.31.0-rc.0~1374 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=70a602dde40e3694f8ef8b9c779a528c17a48f42;hp=744f4c11b0df98d595748cbd34eef6673068cfa8;ds=sidebyside Add SQL for postgres, and fail gracefully in populateIpChanges If the ip_changes table doesn't exist, the populateIpChanges maintenance script will fail gracefully, throwing a descriptive error. The postgres SQL is untested. Bug: T177258 Change-Id: Ic11c64813ee04e8520771bfa156f8e51404273e7 --- diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 91f569f0be..c38eb6aabc 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -482,6 +482,7 @@ class PostgresUpdater extends DatabaseUpdater { [ 'addPgField', 'protected_titles', 'pt_reason_id', 'INTEGER NOT NULL DEFAULT 0' ], [ 'addTable', 'comment', 'patch-comment-table.sql' ], [ 'addIndex', 'site_stats', 'site_stats_pkey', 'patch-site_stats-pk.sql' ], + [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ], ]; } diff --git a/maintenance/populateIpChanges.php b/maintenance/populateIpChanges.php index 178c49a73e..4becf6dd4d 100644 --- a/maintenance/populateIpChanges.php +++ b/maintenance/populateIpChanges.php @@ -62,9 +62,14 @@ TEXT } public function doDBUpdates() { + $dbw = $this->getDB( DB_MASTER ); + + if ( !$dbw->tableExists( 'ip_changes' ) ) { + $this->fatalError( 'ip_changes table does not exist' ); + } + $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); $dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] ); - $dbw = $this->getDB( DB_MASTER ); $throttle = intval( $this->getOption( 'throttle', 0 ) ); $maxRevId = intval( $this->getOption( 'max-rev-id', 0 ) ); $start = $this->getOption( 'rev-id', 0 ); diff --git a/maintenance/postgres/archives/patch-ip_changes.sql b/maintenance/postgres/archives/patch-ip_changes.sql new file mode 100644 index 0000000000..231ea1afd5 --- /dev/null +++ b/maintenance/postgres/archives/patch-ip_changes.sql @@ -0,0 +1,10 @@ +CREATE SEQUENCE ip_changes_ipc_rev_id_seq; + +CREATE TABLE ip_changes ( + ipc_rev_id INTEGER PRIMARY KEY NOT NULL DEFAULT nextval('ip_changes_ipc_rev_id_seq'), + ipc_rev_timestamp TIMESTAMPTZ NOT NULL DEFAULT '', + ipc_hex BYTEA NOT NULL DEFAULT '' +); + +CREATE INDEX ipc_rev_timestamp ON ip_changes (ipc_rev_timestamp); +CREATE INDEX ipc_hex_time ON ip_changes (ipc_hex,ipc_rev_timestamp);