]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 519035: Make the FK for series.creator have ON DELETE CASCADE instead
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Sat, 20 Feb 2010 19:56:59 +0000 (11:56 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Sat, 20 Feb 2010 19:56:59 +0000 (11:56 -0800)
of ON DELETE SET NULL
r=LpSolit, a=LpSolit

Bugzilla/DB/Schema.pm
Bugzilla/Install/DB.pm

index 21c0e7970bd05d9017ff0621db53910923bdfa8b..082fde7ef3931ed7e636d7632ee94da11c402045 100644 (file)
@@ -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',
index 66461bf454661be74916d7eaa1f5d2e64fe4ccd7..28f91a23c743af53bd6e0e33622c1a19ac837f97 100644 (file)
@@ -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__