Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail to upgrade Bugzilla from 3.6 to 4.4

I have Bugzilla installed for several years without upgrading. The version I am using is 3.6.12. Today I try to upgrade it to the latest release 4.4 but fail. I follow the instructions to upgrade Bugzilla using bzr. When I run checksetup.pl, it gives me this:

Updating column setter_id in table flags ...

Old: mediumint

New: mediumint NOT NULL

Updating column setter_id in table flags ...
Old: mediumint
New: mediumint NOT NULL

DBD::mysql::db do failed: Cannot change column 'setter_id': used in a foreign key constraint 'fk_flags_setter_id_profiles_userid' [for Statement "ALTER TABLE flags CHANGE COLUMN setter_id setter_id mediumint NOT NULL"] at Bugzilla/DB.pm line 710.

Bugzilla::DB::bz_alter_column_raw('Bugzilla::DB::Mysql=HASH(0x8663790)', 'flags', 'setter_id', 'HASH(0xc9c8cd8)', 'HASH(0xc9c8ff0)', undef) called at Bugzilla/DB.pm line 669

Bugzilla::DB::bz_alter_column('Bugzilla::DB::Mysql=HASH(0x8663790)', 'flags', 'setter_id', 'HASH(0xc9c8cd8)') called at Bugzilla/Install/DB.pm line 627

Bugzilla::Install::DB::update_table_definitions('HASH(0x3050880)') called at C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\Bugzilla-bzr\checksetup.pl line 169

I am not good at Perl and database. I do not know what does it mean. Can anyone give me a hand? Thank you in advance.

like image 235
Eagle Avatar asked May 31 '13 19:05

Eagle


1 Answers

From https://groups.google.com/forum/#!topic/mozilla.support.bugzilla/w7nqD89cBaQ. You may drop table flags (I have this table empty) and recreate it without foreign key constraint, run checksetup.pl and recreate constraint by command:

alter table flags add CONSTRAINT `fk_flags_setter_id_profiles_userid`FOREIGN KEY (`setter_id`)
REFERENCES `profiles` (`userid`) ON UPDATE CASCADE;

Or edit file DB.pm and add a command SET foreign_key_checks = 0 a line immediately following the line

$dbh = Bugzilla->dbh 
$dbh->do('SET foreign_key_checks = 0');

So I used another way. I modified my dump of and change setter_id column to NOT NULL column. Line

  `setter_id` mediumint(9) DEFAULT NULL,

to

  `setter_id` mediumint(9) NOT NULL,

Here are the SQL commands to run once connected to the bugzilla database:

SET foreign_key_checks = 0;
ALTER TABLE flags MODIFY setter_id mediumint(9) NOT NULL;
SET foreign_key_checks = 1;

Then run checksetup.pl

like image 161
Arci Avatar answered Sep 18 '22 22:09

Arci