summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2008-11-14 07:20:54 +0000
committerMax Kremmel <xing@synapse.plus.com>2008-11-14 07:20:54 +0000
commit372893e2d38a092dc17317f50e9f6ae00d2fc978 (patch)
tree8d03aad95b247ec4f580b4bc3964946c1c1fa40b /admin
parent7d37ed240e54d4651a1a38b4d325c5e54fb4d6d0 (diff)
downloadwiki-372893e2d38a092dc17317f50e9f6ae00d2fc978.tar.gz
wiki-372893e2d38a092dc17317f50e9f6ae00d2fc978.tar.bz2
wiki-372893e2d38a092dc17317f50e9f6ae00d2fc978.zip
try to get column type change upgrades working for all databases.
Diffstat (limited to 'admin')
-rw-r--r--admin/upgrades/1.0.0.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/admin/upgrades/1.0.0.php b/admin/upgrades/1.0.0.php
index fcf6807..02cd919 100644
--- a/admin/upgrades/1.0.0.php
+++ b/admin/upgrades/1.0.0.php
@@ -10,14 +10,44 @@ $infoHash = array(
'description' => "Minor fix to table column type.",
'post_upgrade' => NULL,
);
+
+// all we are doing is change the column type of user_id for wiki_footnotes.
+// postgresql < 8.2 doesn't allow easy column type changing
+// and therefore we need to undergo this annoying dance.
$gBitInstaller->registerPackageUpgrade( $infoHash, array(
array( 'DATADICT' => array(
+ // rename original column
+ array( 'RENAMECOLUMN' => array(
+ 'wiki_footnotes' => array(
+ '`user_id`' => "`temp_column` VARCHAR(40)",
+ ),
+ )),
+ // insert new column
array( 'ALTER' => array(
'wiki_footnotes' => array(
'user_id' => array( '`user_id`', 'I4' ),
))),
)),
+// copy data into new column
+array( 'QUERY' =>
+ // postgres > 8.2 needs to have the type cast
+ array( 'PGSQL' => array(
+ "UPDATE `".BIT_DB_PREFIX."wiki_footnotes` SET `user_id` = `temp_column`::integer",
+ )),
+ array( 'SQL92' => array(
+ "UPDATE `".BIT_DB_PREFIX."wiki_footnotes` SET `user_id` = `temp_column`",
+ )),
+),
+
+array( 'DATADICT' => array(
+ // drop old column
+ array( 'DROPCOLUMN' => array(
+ 'wiki_footnotes' => array( '`temp_column`' ),
+ )),
+ // reconstruct constraints, sequences and indexes
+)),
+
));
?>