From e6ea9c3931636f5ebfb7877da18af28b221cdc58 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Wed, 14 Jul 2010 15:30:39 -0700 Subject: Bug 578739: Instead of removing REFERENCES from _bz_real_schema and then populating FKs from _bz_schema at the end of checksetup, store REFERENCES in _bz_real_schema with a special "created => 0" key that tells us that we still need to create the FK. r=mkanat, a=mkanat (module owner) --- Bugzilla/Install/DB.pm | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'Bugzilla/Install') diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 26e36f7df..225e862de 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -3155,13 +3155,11 @@ sub _add_foreign_keys_to_multiselects { WHERE type = ' . FIELD_TYPE_MULTI_SELECT); foreach my $name (@$names) { - $dbh->bz_add_fk("bug_$name", "bug_id", {TABLE => 'bugs', - COLUMN => 'bug_id', - DELETE => 'CASCADE',}); + $dbh->bz_add_fk("bug_$name", "bug_id", + {TABLE => 'bugs', COLUMN => 'bug_id', DELETE => 'CASCADE'}); - $dbh->bz_add_fk("bug_$name", "value", {TABLE => $name, - COLUMN => 'value', - DELETE => 'RESTRICT',}); + $dbh->bz_add_fk("bug_$name", "value", + {TABLE => $name, COLUMN => 'value', DELETE => 'RESTRICT'}); } } @@ -3380,9 +3378,8 @@ sub _convert_flagtypes_fks_to_set_null { foreach my $column (qw(request_group_id grant_group_id)) { my $fk = $dbh->bz_fk_info('flagtypes', $column); if ($fk and !defined $fk->{DELETE}) { - # checksetup will re-create the FK with the appropriate definition - # at the end of its table upgrades, so we just drop it here. - $dbh->bz_drop_fk('flagtypes', $column); + $fk->{DELETE} = 'SET NULL'; + $dbh->bz_alter_fk('flagtypes', $column, $fk); } } } @@ -3398,10 +3395,9 @@ sub _fix_decimal_types { sub _fix_series_creator_fk { my $dbh = Bugzilla->dbh; my $fk = $dbh->bz_fk_info('series', 'creator'); - # Change the FK from SET NULL to CASCADE. (It will be re-created - # automatically at the end of all DB changes.) if ($fk and $fk->{DELETE} eq 'SET NULL') { - $dbh->bz_drop_fk('series', 'creator'); + $fk->{DELETE} = 'CASCADE'; + $dbh->bz_alter_fk('series', 'creator', $fk); } } -- cgit v1.2.3-24-g4f1b