diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2008-11-14 07:20:54 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2008-11-14 07:20:54 +0000 |
| commit | 189216a402bb0a3cadb789db9f184dd806072a58 (patch) | |
| tree | ce405915c748c3b2ad26bb9d4e9a94f3afe24512 /admin | |
| parent | 4134a88572197750f809b0ee39e04044bf4764f0 (diff) | |
| download | liberty-189216a402bb0a3cadb789db9f184dd806072a58.tar.gz liberty-189216a402bb0a3cadb789db9f184dd806072a58.tar.bz2 liberty-189216a402bb0a3cadb789db9f184dd806072a58.zip | |
try to get column type change upgrades working for all databases.
Diffstat (limited to 'admin')
| -rw-r--r-- | admin/upgrades/2.1.1.php | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/admin/upgrades/2.1.1.php b/admin/upgrades/2.1.1.php index 75696f9..08eea70 100644 --- a/admin/upgrades/2.1.1.php +++ b/admin/upgrades/2.1.1.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_liberty/admin/upgrades/2.1.1.php,v 1.1 2008/11/12 21:57:44 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_liberty/admin/upgrades/2.1.1.php,v 1.2 2008/11/14 07:20:54 squareing Exp $ */ global $gBitInstaller; @@ -12,6 +12,44 @@ $infoHash = array( ); $gBitInstaller->registerPackageUpgrade( $infoHash, array( +// all we are doing is change the column type of user_id for liberty_content_history. +// 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( + 'liberty_content_history' => array( + '`user_id`' => "`temp_column` VARCHAR(40)", + ), + )), + // insert new column + array( 'ALTER' => array( + 'liberty_content_history' => 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."liberty_content_history` SET `user_id` = `temp_column`::integer", + )), + array( 'SQL92' => array( + "UPDATE `".BIT_DB_PREFIX."liberty_content_history` SET `user_id` = `temp_column`", + )), +), + +array( 'DATADICT' => array( + // drop old column + array( 'DROPCOLUMN' => array( + 'liberty_content_history' => array( '`temp_column`' ), + )), + // reconstruct constraints, sequences and indexes +)), + array( 'DATADICT' => array( array( 'ALTER' => array( 'liberty_content_history' => array( |
