diff options
author | mkanat%kerio.com <> | 2005-09-03 08:30:11 +0200 |
---|---|---|
committer | mkanat%kerio.com <> | 2005-09-03 08:30:11 +0200 |
commit | 25ede8ea22c57d678b718fa6005a661ac31fc243 (patch) | |
tree | 40fd64e18e833c89c21d3b4af2e7f91f4ba24f97 | |
parent | c3d52c4bb57cb41cc9f15172146bc3644239881a (diff) | |
download | bugzilla-25ede8ea22c57d678b718fa6005a661ac31fc243.tar.gz bugzilla-25ede8ea22c57d678b718fa6005a661ac31fc243.tar.xz |
Bug 299230: Schema-Modification Functions Shouldn't Die on A DB-side Deletion Failure
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=joel, a=justdave
-rw-r--r-- | Bugzilla/DB.pm | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index fd846d2a5..c67fd4bae 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -513,7 +513,10 @@ sub bz_drop_column { $table, $column); print "Deleting unused column $column from table $table ...\n"; foreach my $sql (@statements) { - $self->do($sql); + # 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: $@"; } $self->_bz_real_schema->delete_column($table, $column); $self->_bz_store_real_schema; @@ -553,7 +556,12 @@ sub bz_drop_index_raw { my @statements = $self->_bz_schema->get_drop_index_ddl( $table, $name); print "Removing index '$name' from the $table table...\n" unless $silent; - $self->do($_) foreach (@statements); + 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: $@"; + } } sub bz_drop_table { @@ -564,7 +572,12 @@ sub bz_drop_table { if ($table_exists) { my @statements = $self->_bz_schema->get_drop_table_ddl($name); print "Dropping table $name...\n"; - $self->do($_) foreach (@statements); + 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: $@"; + } $self->_bz_real_schema->delete_table($name); $self->_bz_store_real_schema; } |