From 7bdfb063ad4800a4fb3ea2fa4742e34da76986f3 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Sat, 20 Feb 2010 20:05:10 +0000 Subject: [PATCH] Bug 519035: Make the FK for series.creator have ON DELETE CASCADE instead of ON DELETE SET NULL r=LpSolit, a=LpSolit git-svn-id: svn://10.0.0.236/trunk@259769 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm | 2 +- mozilla/webtools/bugzilla/Bugzilla/Install/DB.pm | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index d06abf21cd5..9833d88d782 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -7012 \ No newline at end of file +7013 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm b/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm index 21c0e7970bd..082fde7ef39 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm @@ -1248,7 +1248,7 @@ use constant ABSTRACT_SCHEMA => { creator => {TYPE => 'INT3', REFERENCES => {TABLE => 'profiles', COLUMN => 'userid', - DELETE => 'SET NULL'}}, + DELETE => 'CASCADE'}}, category => {TYPE => 'INT2', NOTNULL => 1, REFERENCES => {TABLE => 'series_categories', COLUMN => 'id', diff --git a/mozilla/webtools/bugzilla/Bugzilla/Install/DB.pm b/mozilla/webtools/bugzilla/Bugzilla/Install/DB.pm index 66461bf4546..28f91a23c74 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Install/DB.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Install/DB.pm @@ -598,6 +598,7 @@ sub update_table_definitions { _add_allows_unconfirmed_to_product_table(); _convert_flagtypes_fks_to_set_null(); _fix_decimal_types(); + _fix_series_creator_fk(); # 2009-11-14 dkl@redhat.com - Bug 310450 $dbh->bz_add_column('bugs_activity', 'comment_id', {TYPE => 'INT3'}); @@ -3374,6 +3375,16 @@ sub _fix_decimal_types { $dbh->bz_alter_column('longdescs', 'work_time', $type); } +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'); + } +} + 1; __END__