Commit effe73e5 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'remove-projects_ci_resource_groups_project_id-fk' into 'master'

Swap FK ci_resource_groups to projects for LFK

See merge request gitlab-org/gitlab!78156
parents 6f194bfc fe98ddcc
# frozen_string_literal: true
class RemoveProjectsCiResourceGroupsProjectIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
with_lock_retries do
remove_foreign_key_if_exists(:ci_resource_groups, :projects, name: "fk_774722d144")
end
end
def down
add_concurrent_foreign_key(:ci_resource_groups, :projects, name: "fk_774722d144", column: :project_id, target_column: :id, on_delete: "cascade")
end
end
08d8a5a605058598a2f033bbd461518c502fb3da8627240c5d66f887b43f3ac3
\ No newline at end of file
......@@ -29366,9 +29366,6 @@ ALTER TABLE ONLY vulnerabilities
ALTER TABLE ONLY oauth_openid_requests
ADD CONSTRAINT fk_77114b3b09 FOREIGN KEY (access_grant_id) REFERENCES oauth_access_grants(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_resource_groups
ADD CONSTRAINT fk_774722d144 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY users
ADD CONSTRAINT fk_789cd90b35 FOREIGN KEY (accepted_term_id) REFERENCES application_setting_terms(id) ON DELETE CASCADE;
......@@ -43,6 +43,10 @@ ci_pending_builds:
- table: namespaces
column: namespace_id
on_delete: async_delete
ci_resource_groups:
- table: projects
column: project_id
on_delete: async_delete
ci_runner_namespaces:
- table: namespaces
column: namespace_id
......
......@@ -3,6 +3,11 @@
require 'spec_helper'
RSpec.describe Ci::ResourceGroup do
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:project) }
let!(:model) { create(:ci_resource_group, project: parent) }
end
describe 'validation' do
it 'valids when key includes allowed character' do
resource_group = build(:ci_resource_group, key: 'test')
......
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