diff options
Diffstat (limited to 'db/post_migrate/20220126210022_re_remove_projects_ci_builds_project_id_fk.rb')
-rw-r--r-- | db/post_migrate/20220126210022_re_remove_projects_ci_builds_project_id_fk.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/db/post_migrate/20220126210022_re_remove_projects_ci_builds_project_id_fk.rb b/db/post_migrate/20220126210022_re_remove_projects_ci_builds_project_id_fk.rb new file mode 100644 index 00000000000..2a026388bbf --- /dev/null +++ b/db/post_migrate/20220126210022_re_remove_projects_ci_builds_project_id_fk.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class ReRemoveProjectsCiBuildsProjectIdFk < Gitlab::Database::Migration[1.0] + disable_ddl_transaction! + + def up + return unless foreign_key_exists?(:ci_builds, :projects, name: "fk_befce0568a") + + with_lock_retries do + execute('LOCK projects, ci_builds IN ACCESS EXCLUSIVE MODE') if transaction_open? + + remove_foreign_key_if_exists(:ci_builds, :projects, name: "fk_befce0568a") + end + end + + def down + # no-op, since the FK will be added via rollback by prior-migration + end +end |