From 962be1d210026edb84b4d40b60d3152fb20441cc Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Wed, 1 Dec 2010 20:15:45 +0000 Subject: [PATCH] * Commit changes to PG new-installer I thought I had done last week. * Set up and use function for renaming tables * Use $conn instead of $this when it is called for * remove protection from commitChanges so the installer can use it --- includes/installer/PostgresInstaller.php | 6 ++++-- includes/installer/PostgresUpdater.php | 17 +++++++++++++---- maintenance/postgres/archives/patch-mwuser.sql | 1 - .../postgres/archives/patch-pagecontent.sql | 1 - 4 files changed, 17 insertions(+), 8 deletions(-) delete mode 100644 maintenance/postgres/archives/patch-mwuser.sql delete mode 100644 maintenance/postgres/archives/patch-pagecontent.sql diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index e596073e3d..1eead9c539 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -131,7 +131,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( $conn->tableExists( $ctest, $schema ) ) { $conn->doQuery( "DROP TABLE $safeschema.$ctest" ); } - $res = $this->doQuery( "CREATE TABLE $safeschema.$ctest(a int)" ); + $res = $conn->doQuery( "CREATE TABLE $safeschema.$ctest(a int)" ); if ( !$res ) { $status->fatal( 'config-install-pg-schema-failed', $this->getVar( 'wgDBuser'), $schema ); @@ -141,8 +141,10 @@ class PostgresInstaller extends DatabaseInstaller { return $status; } - protected function commitChanges() { + function commitChanges() { $this->db->query( 'COMMIT' ); + + return Status::newGood(); } function getLocalSettings() { diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 44f5a245fe..a13b45f657 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -5,7 +5,7 @@ * @file * @ingroup Deployment */ - + /** * Class for handling updates to Postgres databases. * @@ -39,9 +39,7 @@ class PostgresUpdater extends DatabaseUpdater { # new tables array( 'addTable', 'category', 'patch-category.sql' ), - array( 'addTable', 'mwuser', 'patch-mwuser.sql' ), array( 'addTable', 'page', 'patch-page.sql' ), - array( 'addTable', 'pagecontent', 'patch-pagecontent.sql' ), array( 'addTable', 'querycachetwo', 'patch-querycachetwo.sql' ), array( 'addTable', 'page_props', 'patch-page_props.sql' ), array( 'addTable', 'page_restrictions', 'patch-page_restrictions.sql' ), @@ -60,6 +58,10 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addTable', 'msg_resource_links','patch-msg_resource_links.sql' ), array( 'addTable', 'module_deps', 'patch-module_deps.sql' ), + # rename tables + array( 'renameTable', 'text', 'pagecontent' ), + array( 'renameTable', 'user', 'mwuser' ), + # Needed before new field array( 'convertArchive2' ), @@ -260,7 +262,7 @@ class PostgresUpdater extends DatabaseUpdater { $fieldRecord[2] ); } - + return $updates; } @@ -399,6 +401,13 @@ END; } } + protected function renameTable( $old, $new ) { + if ( $this->db->tableExists( $old ) ) { + $this->output( "Renaming table $old to $new\n" ); + $this->db->query( "ALTER TABLE \"$old\" RENAME TO $new" ); + } + } + protected function addPgField( $table, $field, $type ) { $fi = $this->db->fieldInfo( $table, $field ); if ( !is_null( $fi ) ) { diff --git a/maintenance/postgres/archives/patch-mwuser.sql b/maintenance/postgres/archives/patch-mwuser.sql deleted file mode 100644 index 3984703ac0..0000000000 --- a/maintenance/postgres/archives/patch-mwuser.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "user" RENAME TO mwuser; diff --git a/maintenance/postgres/archives/patch-pagecontent.sql b/maintenance/postgres/archives/patch-pagecontent.sql deleted file mode 100644 index c3651f92c6..0000000000 --- a/maintenance/postgres/archives/patch-pagecontent.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "text" RENAME TO pagecontent; -- 2.20.1