Skip to content
代码片段 群组 项目
提交 57f8876d 编辑于 作者: moaz-khalifa's avatar moaz-khalifa
浏览文件

Convert upstream_id in virtual_registries_packages_maven_cached_responses into LFK

上级 f220ef98
No related branches found
No related tags found
无相关合并请求
...@@ -466,6 +466,10 @@ user_details: ...@@ -466,6 +466,10 @@ user_details:
- table: namespaces - table: namespaces
column: enterprise_group_id column: enterprise_group_id
on_delete: async_nullify on_delete: async_nullify
virtual_registries_packages_maven_cached_responses:
- table: virtual_registries_packages_maven_upstreams
column: upstream_id
on_delete: async_nullify
vulnerability_export_parts: vulnerability_export_parts:
- table: organizations - table: organizations
column: organization_id column: organization_id
......
# frozen_string_literal: true
class TrackVirtualRegistriesPackagesMavenUpstreamRecordChanges < Gitlab::Database::Migration[2.2]
include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
milestone '17.4'
def up
track_record_deletions(:virtual_registries_packages_maven_upstreams)
end
def down
untrack_record_deletions(:virtual_registries_packages_maven_upstreams)
end
end
# frozen_string_literal: true
class RemoveVregsPkgsMvnUpstreamsVregsPkgsMvnCachedResponsesUpstreamIdFk < Gitlab::Database::Migration[2.2]
milestone '17.4'
disable_ddl_transaction!
FOREIGN_KEY_NAME = 'fk_rails_1167f21441'
def up
with_lock_retries do
remove_foreign_key_if_exists(
:virtual_registries_packages_maven_cached_responses,
:virtual_registries_packages_maven_upstreams,
name: FOREIGN_KEY_NAME,
reverse_lock_order: true
)
end
end
def down
add_concurrent_foreign_key(
:virtual_registries_packages_maven_cached_responses,
:virtual_registries_packages_maven_upstreams,
name: FOREIGN_KEY_NAME,
column: :upstream_id,
target_column: :id,
on_delete: :nullify
)
end
end
a64beea59b93163168802d44712c9637dbb255792feb1aed84025ea7dc03ccc7
\ No newline at end of file
1254dd3a1d7e28ab9866877ad278d370c93949d7f0dd9973283c745e4fe5cdf8
\ No newline at end of file
...@@ -32874,6 +32874,8 @@ CREATE TRIGGER trigger_update_vulnerability_reads_on_vulnerability_update AFTER ...@@ -32874,6 +32874,8 @@ CREATE TRIGGER trigger_update_vulnerability_reads_on_vulnerability_update AFTER
   
CREATE TRIGGER users_loose_fk_trigger AFTER DELETE ON users REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records(); CREATE TRIGGER users_loose_fk_trigger AFTER DELETE ON users REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
   
CREATE TRIGGER virtual_registries_packages_maven_upstreams_loose_fk_trigger AFTER DELETE ON virtual_registries_packages_maven_upstreams REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
ALTER TABLE ONLY deployments ALTER TABLE ONLY deployments
ADD CONSTRAINT fk_009fd21147 FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE; ADD CONSTRAINT fk_009fd21147 FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE;
   
...@@ -34599,9 +34601,6 @@ ALTER TABLE ONLY ci_sources_projects ...@@ -34599,9 +34601,6 @@ ALTER TABLE ONLY ci_sources_projects
ALTER TABLE ONLY ci_sources_projects ALTER TABLE ONLY ci_sources_projects
ADD CONSTRAINT fk_rails_10a1eb379a_p_tmp FOREIGN KEY (partition_id, pipeline_id) REFERENCES p_ci_pipelines(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID; ADD CONSTRAINT fk_rails_10a1eb379a_p_tmp FOREIGN KEY (partition_id, pipeline_id) REFERENCES p_ci_pipelines(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
   
ALTER TABLE ONLY virtual_registries_packages_maven_cached_responses
ADD CONSTRAINT fk_rails_1167f21441 FOREIGN KEY (upstream_id) REFERENCES virtual_registries_packages_maven_upstreams(id) ON DELETE SET NULL;
ALTER TABLE ONLY zoom_meetings ALTER TABLE ONLY zoom_meetings
ADD CONSTRAINT fk_rails_1190f0e0fa FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_1190f0e0fa FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
   
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
class: 'VirtualRegistries::Packages::Maven::CachedResponse' do class: 'VirtualRegistries::Packages::Maven::CachedResponse' do
upstream { association :virtual_registries_packages_maven_upstream } upstream { association :virtual_registries_packages_maven_upstream }
group { upstream.group } group { upstream.group }
relative_path { '/a/relative/path/test.txt' } relative_path { |n| "/a/relative/path/test-#{n}.txt" }
size { 1.kilobyte } size { 1.kilobyte }
upstream_etag { OpenSSL::Digest.hexdigest('SHA256', 'test') } upstream_etag { OpenSSL::Digest.hexdigest('SHA256', 'test') }
content_type { 'text/plain' } content_type { 'text/plain' }
......
...@@ -114,4 +114,11 @@ ...@@ -114,4 +114,11 @@
it { is_expected.to contain_exactly(cached_response) } it { is_expected.to contain_exactly(cached_response) }
end end
end end
context 'with loose foreign key on virtual_registries_packages_maven_cached_responses.upstream_id' do
it_behaves_like 'cleanup by a loose foreign key' do
let_it_be(:parent) { create(:virtual_registries_packages_maven_upstream) }
let_it_be(:model) { create(:virtual_registries_packages_maven_cached_response, upstream: parent) }
end
end
end end
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
subject(:upstream) { build(:virtual_registries_packages_maven_upstream) } subject(:upstream) { build(:virtual_registries_packages_maven_upstream) }
it_behaves_like 'it has loose foreign keys' do
let(:factory_name) { :virtual_registries_packages_maven_upstream }
end
describe 'associations' do describe 'associations' do
it do it do
is_expected.to have_many(:cached_responses) is_expected.to have_many(:cached_responses)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册