summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Install
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2008-06-29 02:17:47 +0200
committermkanat%bugzilla.org <>2008-06-29 02:17:47 +0200
commit66146a6e56c9a23cad32a6cbf897018372c07e80 (patch)
tree3c29f5ae9484ccfae1d150ab048e47ffe1ca9dff /Bugzilla/Install
parenta6f41ad1a4ff69fd050ba4a3e9e7c3fa8033de51 (diff)
downloadbugzilla-66146a6e56c9a23cad32a6cbf897018372c07e80.tar.gz
bugzilla-66146a6e56c9a23cad32a6cbf897018372c07e80.tar.xz
Bug 429804: Add Foreign Keys to Multiselect fields
Patch By Alex Eiser <aeiser@arc.nasa.gov> r=mkanat, a=mkanat
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r--Bugzilla/Install/DB.pm22
1 files changed, 22 insertions, 0 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index d1f1aadb5..54dbfc564 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -526,6 +526,9 @@ sub update_table_definitions {
$dbh->bz_alter_column('series', 'query',
{ TYPE => 'MEDIUMTEXT', NOTNULL => 1 });
+ # Add FK to multi select field tables
+ _add_foreign_keys_to_multiselects();
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
@@ -2993,6 +2996,25 @@ sub _check_content_length {
}
}
+sub _add_foreign_keys_to_multiselects {
+ my $dbh = Bugzilla->dbh;
+
+ my $names = $dbh->selectcol_arrayref(
+ 'SELECT name
+ FROM fielddefs
+ 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", "value", {TABLE => $name,
+ COLUMN => 'value',
+ DELETE => 'RESTRICT',});
+ }
+}
+
sub _populate_bugs_fulltext {
my $dbh = Bugzilla->dbh;
my $fulltext = $dbh->selectrow_array('SELECT 1 FROM bugs_fulltext '