1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
<?php
/**
*/
global $gBitInstaller;
$infoHash = array(
'package' => WIKI_PKG_NAME,
'version' => str_replace( '.php', '', basename( __FILE__ )),
'description' => "Minor fix to user_id column type in wiki_footnotes.",
'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" ),
'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
)),
));
?>
|