summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB.pm
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2012-01-09 21:56:14 +0100
committerDave Lawrence <dlawrence@mozilla.com>2012-01-09 21:56:14 +0100
commit0c449e2d96804f6e48d3812b42ccf407fbbeb747 (patch)
treedfdd8c56789ff02c925b5b55e11faf890f1ecd98 /Bugzilla/DB.pm
parentddf1fb2abb2a6266ce5a9cc525c84563c154df52 (diff)
parenta7785661b8e7dcb7a6914eebf1a11fd99f1cf037 (diff)
downloadbugzilla-0c449e2d96804f6e48d3812b42ccf407fbbeb747.tar.gz
bugzilla-0c449e2d96804f6e48d3812b42ccf407fbbeb747.tar.xz
merge with bugzilla/4.2
Diffstat (limited to 'Bugzilla/DB.pm')
-rw-r--r--Bugzilla/DB.pm14
1 files changed, 13 insertions, 1 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 083a1c208..0c841632f 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -548,7 +548,7 @@ sub bz_setup_foreign_keys {
# prior to 4.2, and also to handle problems caused
# by enabling an extension pre-4.2, disabling it for
# the 4.2 upgrade, and then re-enabling it later.
- if (!$fk) {
+ unless ($fk && $fk->{created}) {
my $standard_def =
$self->_bz_schema->get_column_abstract($table, $column);
if (exists $standard_def->{REFERENCES}) {
@@ -1058,6 +1058,18 @@ sub bz_rename_table {
my $new = $self->bz_table_info($new_name);
ThrowCodeError('db_rename_conflict', { old => $old_name,
new => $new_name }) if $new;
+
+ # FKs will all have the wrong names unless we drop and then let them
+ # be re-created later. Under normal circumstances, checksetup.pl will
+ # automatically re-create these dropped FKs at the end of its DB upgrade
+ # run, so we don't need to re-create them in this method.
+ my @columns = $self->bz_table_columns($old_name);
+ foreach my $column (@columns) {
+ # these just return silently if there's no FK to drop
+ $self->bz_drop_fk($old_name, $column);
+ $self->bz_drop_related_fks($old_name, $column);
+ }
+
my @sql = $self->_bz_real_schema->get_rename_table_sql($old_name, $new_name);
print get_text('install_table_rename',
{ old => $old_name, new => $new_name }) . "\n"