]> 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:57:47 +0000 (11:57 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Sat, 20 Feb 2010 19:57:47 +0000 (11:57 -0800)
of ON DELETE SET NULL
r=LpSolit, a=LpSolit

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

index 8bee5dfe13d043e007e912573d3e7d71e9b0ea49..76943fe1aeeb08f1a3e368dca88c74633bd84ec9 100644 (file)
@@ -1270,7 +1270,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 f6d6edcb1dc9f397481d407ff381370fd91a7b36..3ea770be68a1357d80d66910e3185bd2f858e870 100644 (file)
@@ -595,6 +595,7 @@ sub update_table_definitions {
     _add_allows_unconfirmed_to_product_table();
     _convert_flagtypes_fks_to_set_null();
     _fix_decimal_types();
+    _fix_series_creator_fk();
 
     ################################################################
     # New --TABLE-- changes should go *** A B O V E *** this point #
@@ -3362,6 +3363,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__