From: Max Kanat-Alexander Date: Thu, 8 Jul 2010 23:44:27 +0000 (-0700) Subject: Bug 577577: Make bz_drop_fk be tolerant of SQL failure X-Git-Tag: bugzilla-3.6.2~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b27e9d71ecc397fea623371281afac01c39fb85;p=thirdparty%2Fbugzilla.git Bug 577577: Make bz_drop_fk be tolerant of SQL failure r=mkanat, a=mkanat (module owner) --- diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 830d2835e7..92d4e0c11c 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -745,8 +745,14 @@ sub bz_drop_fk { print get_text('install_fk_drop', { table => $table, column => $column, fk => $def }) . "\n" if Bugzilla->usage_mode == USAGE_MODE_CMDLINE; - my @sql = $self->_bz_real_schema->get_drop_fk_sql($table,$column,$def); - $self->do($_) foreach @sql; + my @statements = + $self->_bz_real_schema->get_drop_fk_sql($table,$column,$def); + foreach my $sql (@statements) { + # Because this is a deletion, we don't want to die hard if + # we fail because of some local customization. If something + # is already gone, that's fine with us! + eval { $self->do($sql); } or warn "Failed SQL: [$sql] Error: $@"; + } delete $col_def->{REFERENCES}; $self->_bz_real_schema->set_column($table, $column, $col_def); $self->_bz_store_real_schema;