diff options
author | Stan Hu <stanhu@gmail.com> | 2017-08-20 03:28:25 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-08-20 03:32:31 -0700 |
commit | 718ecd4eb5976d1005664dfbd84ee9d9c263e3b9 (patch) | |
tree | ed2d68be41c22e1886df34920d1195374ae33984 /lib | |
parent | 84336b848caec71b9c2af2d826cf81e6a258f6e2 (diff) | |
download | gitlab-ce-718ecd4eb5976d1005664dfbd84ee9d9c263e3b9.tar.gz |
Fix Error 500s when attempting to destroy a protected tag
Due to a missing `on_delete: :cascade`, users would hit the error that
looked like:
```
PG::ForeignKeyViolation: ERROR: update or delete on table "protected_tags"
violates foreign key constraint "fk_rails_f7dfda8c51" on table
"protected_tag_create_access_levels" DETAIL: Key (id)=(1385) is still
referenced from table "protected_tag_create_access_levels". : DELETE FROM
"protected_tags" WHERE "protected_tags"."id" = 1385
```
Closes #36013
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 69ca9aa596b..b83e633c7ed 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -606,6 +606,11 @@ module Gitlab Arel::Nodes::SqlLiteral.new(replace.to_sql) end end + + def remove_foreign_key_without_error(*args) + remove_foreign_key(*args) + rescue ArgumentError + end end end end |