MusikAnimal has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391058 )

Change subject: Add SQL for postgres, and fail gracefully in populateIpChanges
......................................................................

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
---
M maintenance/populateIpChanges.php
A maintenance/postgres/archives/patch-ip_changes.sql
2 files changed, 17 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/58/391058/1

diff --git a/maintenance/populateIpChanges.php 
b/maintenance/populateIpChanges.php
index 178c49a..b2b920c 100644
--- a/maintenance/populateIpChanges.php
+++ b/maintenance/populateIpChanges.php
@@ -62,9 +62,15 @@
        }
 
        public function doDBUpdates() {
+               $dbw = $this->getDB( DB_MASTER );
+
+               if ( !$dbw->tableExists( 'ip_changes' ) ) {
+                       $this->error( 'ip_changes table does not exist' );
+                       return false;
+               }
+
                $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 0000000..231ea1a
--- /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);

-- 
To view, visit https://gerrit.wikimedia.org/r/391058
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic11c64813ee04e8520771bfa156f8e51404273e7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MusikAnimal <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to