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

Change subject: Move MssqlUpdater::updateSchema to DatabaseUpdater
......................................................................

Move MssqlUpdater::updateSchema to DatabaseUpdater

While working on a schema change that involves changing default values
for about six columns I noticed that there currently is no high-level
function within DatabaseUpdate to run a change on multiple columns in a
single sql file. The most abstract function is modifyField which allows
whatever changes one likes to a specific column on a specific table. For
my schema change (ref T56888), splitting up the sql files to be one file
per column would end up in 6 columns * 5 supported databases = 30 sql
files.

I noticed that the MssqlUpdater class has a better function for such
changes called schemaUpdate. It works on basis of a given table name but
does not ask for a specific column name. For that reason, it is suitable
to use this function for schema changes to multiple columns. This
function also is in no way specific to Mssql and there is no function
named schemaUpdate in DatabaseUpdater or any of it's subclasses (besides
MssqlUpdater) so the function can safely be moved to DatabaseUpdater,
making it available for usage on all supported database systems.

Change-Id: Id2a1583cd9efa5ef271ae67238119bc24b76a3c6
---
M includes/installer/DatabaseUpdater.php
M includes/installer/MssqlUpdater.php
2 files changed, 23 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/16/352216/1

diff --git a/includes/installer/DatabaseUpdater.php 
b/includes/installer/DatabaseUpdater.php
index a4cb695..a83afa3 100644
--- a/includes/installer/DatabaseUpdater.php
+++ b/includes/installer/DatabaseUpdater.php
@@ -935,6 +935,29 @@
        }
 
        /**
+        * General schema update for a table that touches more than one field 
or requires
+        * destructive actions (such as dropping and recreating the table).
+        *
+        * @param string $table
+        * @param string $updatekey
+        * @param string $patch
+        * @param bool $fullpath
+        */
+       protected function updateSchema( $table, $updatekey, $patch, $fullpath 
= false ) {
+               if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
+                       $this->output( "...$table table does not exist, 
skipping schema update patch.\n" );
+               } elseif ( $this->updateRowExists( $updatekey ) ) {
+                       $this->output( "...$table already had schema updated by 
$patch.\n" );
+               } else {
+                       $this->insertUpdateRow( $updatekey );
+
+                       return $this->applyPatch( $patch, $fullpath, "Updating 
schema of table $table" );
+               }
+
+               return true;
+       }
+
+       /**
         * Set any .htaccess files or equivilent for storage repos
         *
         * Some zones (e.g. "temp") used to be public and may have been 
initialized as such
diff --git a/includes/installer/MssqlUpdater.php 
b/includes/installer/MssqlUpdater.php
index dfe595e..c03e8e4 100644
--- a/includes/installer/MssqlUpdater.php
+++ b/includes/installer/MssqlUpdater.php
@@ -112,26 +112,4 @@
                $this->db->prepareStatements( $prevPrep );
        }
 
-       /**
-        * General schema update for a table that touches more than one field 
or requires
-        * destructive actions (such as dropping and recreating the table).
-        *
-        * @param string $table
-        * @param string $updatekey
-        * @param string $patch
-        * @param bool $fullpath
-        */
-       protected function updateSchema( $table, $updatekey, $patch, $fullpath 
= false ) {
-               if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
-                       $this->output( "...$table table does not exist, 
skipping schema update patch.\n" );
-               } elseif ( $this->updateRowExists( $updatekey ) ) {
-                       $this->output( "...$table already had schema updated by 
$patch.\n" );
-               } else {
-                       $this->insertUpdateRow( $updatekey );
-
-                       return $this->applyPatch( $patch, $fullpath, "Updating 
schema of table $table" );
-               }
-
-               return true;
-       }
 }

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

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

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

Reply via email to