Commit eab9a1fe authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '348274-remove-foreign-key-dast_scanner_profiles_builds-ci_build_id' into 'master'

Swap FK dast_scanner_profiles_builds.ci_build_id to ci_builds for LFK

See merge request gitlab-org/gitlab!77910
parents b1d3cb19 f7e3cb79
# frozen_string_literal: true
class RemoveDastScannerProfilesBuildsCiBuildIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
CONSTRAINT_NAME = 'fk_e4c49200f8'
def up
with_lock_retries do
execute('LOCK ci_builds, dast_scanner_profiles_builds IN ACCESS EXCLUSIVE MODE')
remove_foreign_key_if_exists(:dast_scanner_profiles_builds, :ci_builds, name: CONSTRAINT_NAME)
end
end
def down
add_concurrent_foreign_key(:dast_scanner_profiles_builds, :ci_builds, column: :ci_build_id, on_delete: :cascade, name: CONSTRAINT_NAME)
end
end
d8b206e26f6dd7e9d5f2b2d8cc5ce2e2bbe2d8d33317948f8cf110fe41872a5d
\ No newline at end of file
......@@ -29909,9 +29909,6 @@ ALTER TABLE ONLY gitlab_subscriptions
ALTER TABLE ONLY ci_triggers
ADD CONSTRAINT fk_e3e63f966e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY dast_scanner_profiles_builds
ADD CONSTRAINT fk_e4c49200f8 FOREIGN KEY (ci_build_id) REFERENCES ci_builds(id) ON DELETE CASCADE;
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_e719a85f8a FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
......@@ -27,4 +27,9 @@ RSpec.describe Dast::ScannerProfilesBuild, type: :model do
end
end
end
it_behaves_like 'cleanup by a loose foreign key' do
let!(:model) { create(:dast_scanner_profiles_build) }
let(:parent) { model.ci_build }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment