Skip to content

Commit

Permalink
Fix #3449: Database upgrade script fails to detect some existing colu…
Browse files Browse the repository at this point in the history
…mns.

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2312 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Jeroen Latour committed Feb 6, 2004
1 parent 04c45db commit 95eb3e6
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 23 deletions.
66 changes: 55 additions & 11 deletions admin/upgrades/0_15_inc.php
Expand Up @@ -8,25 +8,55 @@
# Changes applied to 0.15 database to give us 0.16

# --------------------------------------------------------
# $Id: 0_15_inc.php,v 1.4 2004-01-11 07:16:09 vboctor Exp $
# $Id: 0_15_inc.php,v 1.5 2004-02-06 14:33:25 jlatour Exp $
# --------------------------------------------------------
?>
<?php
require_once( 'db_table_names_inc.php' );

$upgrades = array();

$upgrades[] = new SQLUpgrade(
$upgrades[] = new FunctionUpgrade(
'0.15-1',
'Add file type column to bug file table',
"ALTER TABLE $t_bug_file_table ADD file_type VARCHAR(250) NOT NULL AFTER filesize"
);
'upgrade_0_15_1' );

function upgrade_0_15_1() {
global $t_bug_file_table;

if ( !db_field_exists( 'file_type', $t_bug_file_table ) ) {
$query = "ALTER TABLE $t_bug_file_table ADD file_type VARCHAR(250) NOT NULL AFTER filesize";

$result = @db_query( $query );

if ( false == $result ) {
return false;
}
}

return true;
}

$upgrades[] = new SQLUpgrade(
$upgrades[] = new FunctionUpgrade(
'0.15-2',
'Add file type column to project file table',
"ALTER TABLE $t_project_file_table ADD file_type VARCHAR(250) NOT NULL AFTER filesize"
);
'upgrade_0_15_2' );

function upgrade_0_15_2() {
global $t_project_file_table;

if ( !db_field_exists( 'file_type', $t_project_file_table ) ) {
$query = "ALTER TABLE $t_project_file_table ADD file_type VARCHAR(250) NOT NULL AFTER filesize";

$result = @db_query( $query );

if ( false == $result ) {
return false;
}
}

return true;
}

$upgrades[] = new SQLUpgrade(
'0.15-3',
Expand Down Expand Up @@ -73,12 +103,26 @@
);


$upgrades[] = new SQLUpgrade(
$upgrades[] = new FunctionUpgrade(
'0.15-9',
'Add order field to project version table',
"ALTER TABLE $t_project_version_table ADD date_order DATETIME DEFAULT '1970-01-01 00:00:01' NOT NULL"
);

'upgrade_0_15_9' );

function upgrade_0_15_9() {
global $t_project_version_table;

if ( !db_field_exists( 'date_order', $t_project_version_table ) ) {
$query = "ALTER TABLE $t_project_version_table ADD date_order DATETIME DEFAULT '1970-01-01 00:00:01' NOT NULL";

$result = @db_query( $query );

if ( false == $result ) {
return false;
}
}

return true;
}

return $upgrades;
?>
68 changes: 56 additions & 12 deletions admin/upgrades/0_16_inc.php
Expand Up @@ -8,7 +8,7 @@
# Changes applied to 0.16 database to give us 0.17

# --------------------------------------------------------
# $Id: 0_16_inc.php,v 1.4 2004-01-11 07:16:09 vboctor Exp $
# $Id: 0_16_inc.php,v 1.5 2004-02-06 14:33:25 jlatour Exp $
# --------------------------------------------------------
?>
<?php
Expand Down Expand Up @@ -54,18 +54,47 @@
);


$upgrades[] = new SQLUpgrade(
$upgrades[] = new FunctionUpgrade(
'0.16-7',
'Add view_state to bug table',
"ALTER TABLE $t_bug_table ADD view_state INT(2) DEFAULT '10' NOT NULL AFTER profile_id"
);

$upgrades[] = new SQLUpgrade(
'upgrade_0_16_7' );

function upgrade_0_16_7() {
global $t_bug_table;

if ( !db_field_exists( 'view_state', $t_bug_table ) ) {
$query = "ALTER TABLE $t_bug_table ADD view_state INT(2) DEFAULT '10' NOT NULL AFTER profile_id";

$result = @db_query( $query );

if ( false == $result ) {
return false;
}
}

return true;
}

$upgrades[] = new FunctionUpgrade(
'0.16-8',
'Add view_state to bugnote table',
"ALTER TABLE $t_bugnote_table ADD view_state INT(2) DEFAULT '10' NOT NULL AFTER bugnote_text_id"
);

'upgrade_0_16_8' );

function upgrade_0_16_8() {
global $t_bugnote_table;

if ( !db_field_exists( 'view_state', $t_bugnote_table ) ) {
$query = "ALTER TABLE $t_bugnote_table ADD view_state INT(2) DEFAULT '10' NOT NULL AFTER bugnote_text_id";

$result = @db_query( $query );

if ( false == $result ) {
return false;
}
}

return true;
}

$upgrades[] = new SQLUpgrade(
'0.16-9',
Expand All @@ -91,11 +120,26 @@
"ALTER TABLE $t_bug_table CHANGE version version VARCHAR(64) NOT NULL"
);

$upgrades[] = new SQLUpgrade(
$upgrades[] = new FunctionUpgrade(
'0.16-13',
'Add project_id to user pref table',
"ALTER TABLE $t_user_pref_table ADD project_id INT(7) UNSIGNED ZEROFILL NOT NULL AFTER user_id"
);
'upgrade_0_16_13' );

function upgrade_0_16_13() {
global $t_user_pref_table;

if ( !db_field_exists( 'project_id', $t_user_pref_table ) ) {
$query = "ALTER TABLE $t_user_pref_table ADD project_id INT(7) UNSIGNED ZEROFILL NOT NULL AFTER user_id";

$result = @db_query( $query );

if ( false == $result ) {
return false;
}
}

return true;
}

$upgrades[] = new SQLUpgrade(
'0.16-14',
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeLog
Expand Up @@ -13,6 +13,7 @@ Mantis ChangeLog
* Fix #3396: Database upgrade 0.17-jf-10 failed to upgrade.
* Fix #3400: Reopen a 'closed' bug, the value of 'resolution' is 'reopen' and can't be changed (now resolution / duplicate id can be edited)
* Sec #3445: User see all information from all projects (if user has access to 0 projects)
* Fix #3449: Database upgrade script fails to detect some existing columns.
* Fix #3467: Delete user ends up at user not found error.
* Fix #3475: Reopen bug to custom status possibility.
* Fix #3479: Reset account preferences of a user results in reset administrators (current) account.
Expand Down

0 comments on commit 95eb3e6

Please sign in to comment.