Commit 0177b39f authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '348269-remove-foreign-key-ci_group_variables-group_id' into 'master'

Remove foreign key ci_group_variables.group_id as we have loose fK

See merge request gitlab-org/gitlab!77494
parents a7fd39d3 ed2adc84
# frozen_string_literal: true
class RemoveForeignKeyCiGroupVariablesGroupId < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
CONSTRAINT_NAME = 'fk_33ae4d58d8'
def up
with_lock_retries do
remove_foreign_key_if_exists(:ci_group_variables, :namespaces, name: CONSTRAINT_NAME)
end
end
def down
add_concurrent_foreign_key :ci_group_variables, :namespaces, column: :group_id, on_delete: :cascade, name: CONSTRAINT_NAME
end
end
fa87b087b576d320f94028444a082b920870a2554209808849f9f3f42ead83c4
\ No newline at end of file
...@@ -29179,9 +29179,6 @@ ALTER TABLE ONLY approvals ...@@ -29179,9 +29179,6 @@ ALTER TABLE ONLY approvals
ALTER TABLE ONLY namespaces ALTER TABLE ONLY namespaces
ADD CONSTRAINT fk_319256d87a FOREIGN KEY (file_template_project_id) REFERENCES projects(id) ON DELETE SET NULL; ADD CONSTRAINT fk_319256d87a FOREIGN KEY (file_template_project_id) REFERENCES projects(id) ON DELETE SET NULL;
ALTER TABLE ONLY ci_group_variables
ADD CONSTRAINT fk_33ae4d58d8 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY namespaces ALTER TABLE ONLY namespaces
ADD CONSTRAINT fk_3448c97865 FOREIGN KEY (push_rule_id) REFERENCES push_rules(id) ON DELETE SET NULL; ADD CONSTRAINT fk_3448c97865 FOREIGN KEY (push_rule_id) REFERENCES push_rules(id) ON DELETE SET NULL;
...@@ -42,4 +42,10 @@ RSpec.describe Ci::GroupVariable do ...@@ -42,4 +42,10 @@ RSpec.describe Ci::GroupVariable do
end end
end end
end end
it_behaves_like 'cleanup by a loose foreign key' do
let!(:model) { create(:ci_group_variable) }
let!(:parent) { model.group }
end
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