Commit a36e640b authored by Kamil Trzciński's avatar Kamil Trzciński

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

LFK: Remove foreign key dast_site_profiles_builds.ci_build_id

See merge request gitlab-org/gitlab!77916
parents 89afb6b4 0446e516
# frozen_string_literal: true
class RemoveDastSiteProfilesBuildsCiBuildIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
CONSTRAINT_NAME = 'fk_a325505e99'
def up
with_lock_retries do
execute('LOCK ci_builds, dast_site_profiles_builds IN ACCESS EXCLUSIVE MODE')
remove_foreign_key_if_exists(:dast_site_profiles_builds, :ci_builds, name: CONSTRAINT_NAME)
end
end
def down
add_concurrent_foreign_key(:dast_site_profiles_builds, :ci_builds, column: :ci_build_id, on_delete: :cascade, name: CONSTRAINT_NAME)
end
end
e7d9d79ffb8989ab39fe719217f22736244df70c2b1461ef5a1a3f1e74e43870
\ No newline at end of file
......@@ -29654,9 +29654,6 @@ ALTER TABLE ONLY ci_builds
ALTER TABLE ONLY ci_pipelines
ADD CONSTRAINT fk_a23be95014 FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
ALTER TABLE ONLY dast_site_profiles_builds
ADD CONSTRAINT fk_a325505e99 FOREIGN KEY (ci_build_id) REFERENCES ci_builds(id) ON DELETE CASCADE;
ALTER TABLE ONLY bulk_import_entities
ADD CONSTRAINT fk_a44ff95be5 FOREIGN KEY (parent_id) REFERENCES bulk_import_entities(id) ON DELETE CASCADE;
......@@ -27,4 +27,9 @@ RSpec.describe Dast::SiteProfilesBuild, type: :model do
end
end
end
it_behaves_like 'cleanup by a loose foreign key' do
let!(:model) { create(:dast_site_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