* Commit changes to PG new-installer I thought I had done last week.
authorMark A. Hershberger <mah@users.mediawiki.org>
Wed, 1 Dec 2010 20:15:45 +0000 (20:15 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Wed, 1 Dec 2010 20:15:45 +0000 (20:15 +0000)
* 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
includes/installer/PostgresUpdater.php
maintenance/postgres/archives/patch-mwuser.sql [deleted file]
maintenance/postgres/archives/patch-pagecontent.sql [deleted file]

index e596073..1eead9c 100644 (file)
@@ -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() {
index 44f5a24..a13b45f 100644 (file)
@@ -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 (file)
index 3984703..0000000
+++ /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 (file)
index c3651f9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE "text" RENAME TO pagecontent;