Commit 77bdbbf9 authored by David Fernandez's avatar David Fernandez Committed by Dylan Griffith

Add loose FK between package tables and ci pipelines

parent a70428b3
...@@ -82,8 +82,6 @@ module Ci ...@@ -82,8 +82,6 @@ module Ci
# Merge requests for which the current pipeline is running against # Merge requests for which the current pipeline is running against
# the merge request's latest commit. # the merge request's latest commit.
has_many :merge_requests_as_head_pipeline, foreign_key: "head_pipeline_id", class_name: 'MergeRequest' has_many :merge_requests_as_head_pipeline, foreign_key: "head_pipeline_id", class_name: 'MergeRequest'
has_many :package_build_infos, class_name: 'Packages::BuildInfo', dependent: :nullify, inverse_of: :pipeline # rubocop:disable Cop/ActiveRecordDependent
has_many :package_file_build_infos, class_name: 'Packages::PackageFileBuildInfo', dependent: :nullify, inverse_of: :pipeline # rubocop:disable Cop/ActiveRecordDependent
has_many :pending_builds, -> { pending }, foreign_key: :commit_id, class_name: 'Ci::Build', inverse_of: :pipeline has_many :pending_builds, -> { pending }, foreign_key: :commit_id, class_name: 'Ci::Build', inverse_of: :pipeline
has_many :failed_builds, -> { latest.failed }, foreign_key: :commit_id, class_name: 'Ci::Build', inverse_of: :pipeline has_many :failed_builds, -> { latest.failed }, foreign_key: :commit_id, class_name: 'Ci::Build', inverse_of: :pipeline
has_many :retryable_builds, -> { latest.failed_or_canceled.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build', inverse_of: :pipeline has_many :retryable_builds, -> { latest.failed_or_canceled.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build', inverse_of: :pipeline
......
...@@ -29,3 +29,11 @@ ci_project_mirrors: ...@@ -29,3 +29,11 @@ ci_project_mirrors:
- table: namespaces - table: namespaces
column: namespace_id column: namespace_id
on_delete: async_delete on_delete: async_delete
packages_build_infos:
- table: ci_pipelines
column: pipeline_id
on_delete: async_nullify
packages_package_file_build_infos:
- table: ci_pipelines
column: pipeline_id
on_delete: async_nullify
...@@ -66,8 +66,6 @@ RSpec.describe 'Database schema' do ...@@ -66,8 +66,6 @@ RSpec.describe 'Database schema' do
oauth_access_grants: %w[resource_owner_id application_id], oauth_access_grants: %w[resource_owner_id application_id],
oauth_access_tokens: %w[resource_owner_id application_id], oauth_access_tokens: %w[resource_owner_id application_id],
oauth_applications: %w[owner_id], oauth_applications: %w[owner_id],
packages_build_infos: %w[pipeline_id],
packages_package_file_build_infos: %w[pipeline_id],
product_analytics_events_experimental: %w[event_id txn_id user_id], product_analytics_events_experimental: %w[event_id txn_id user_id],
project_group_links: %w[group_id], project_group_links: %w[group_id],
project_statistics: %w[namespace_id], project_statistics: %w[namespace_id],
......
...@@ -35,8 +35,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do ...@@ -35,8 +35,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
it { is_expected.to have_many(:sourced_pipelines) } it { is_expected.to have_many(:sourced_pipelines) }
it { is_expected.to have_many(:triggered_pipelines) } it { is_expected.to have_many(:triggered_pipelines) }
it { is_expected.to have_many(:pipeline_artifacts) } it { is_expected.to have_many(:pipeline_artifacts) }
it { is_expected.to have_many(:package_build_infos).dependent(:nullify).inverse_of(:pipeline) }
it { is_expected.to have_many(:package_file_build_infos).dependent(:nullify).inverse_of(:pipeline) }
it { is_expected.to have_one(:chat_data) } it { is_expected.to have_one(:chat_data) }
it { is_expected.to have_one(:source_pipeline) } it { is_expected.to have_one(:source_pipeline) }
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
- "./spec/controllers/admin/users_controller_spec.rb" - "./spec/controllers/admin/users_controller_spec.rb"
- "./spec/controllers/omniauth_callbacks_controller_spec.rb" - "./spec/controllers/omniauth_callbacks_controller_spec.rb"
- "./spec/controllers/projects/issues_controller_spec.rb" - "./spec/controllers/projects/issues_controller_spec.rb"
- "./spec/controllers/projects/pipelines_controller_spec.rb"
- "./spec/controllers/projects/settings/access_tokens_controller_spec.rb" - "./spec/controllers/projects/settings/access_tokens_controller_spec.rb"
- "./spec/features/issues/issue_detail_spec.rb" - "./spec/features/issues/issue_detail_spec.rb"
- "./spec/features/projects/pipelines/pipeline_spec.rb" - "./spec/features/projects/pipelines/pipeline_spec.rb"
......
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