From 2be6937da6fae2da651867eb29c680a3de084254 Mon Sep 17 00:00:00 2001 From: Michael Becker <11881043-wandering_person@users.noreply.gitlab.com> Date: Mon, 13 Nov 2023 18:46:53 +0700 Subject: [PATCH] Ignore `epic_id` column on `vulnerabilities` table `epic_id` is always `nil` in production: ```sh [ gstg ] production> Vulnerability.where.not(epic_id: nil).count => 0 [ gstg ] production> ``` It was added [when the initial vulnerability table][1] was created, however appears to have never been used. This MR ignores the column for step 1 of the [3-M drop column process][0] related to: https://gitlab.com/gitlab-org/gitlab/-/issues/268154 Changelog: deprecated [0]:https://docs.gitlab.com/ee/development/database/avoiding_downtime_in_migrations.html#dropping-columns [1]:https://gitlab.com/gitlab-org/gitlab/-/commit/8ad1881cc83fa970bf69103e2fcf1ea4175230ff --- app/models/vulnerability.rb | 2 +- ee/app/models/ee/vulnerability.rb | 2 -- ee/spec/models/ee/vulnerability_spec.rb | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/models/vulnerability.rb b/app/models/vulnerability.rb index abdf585af8123a..1dff78354db5f1 100644 --- a/app/models/vulnerability.rb +++ b/app/models/vulnerability.rb @@ -5,7 +5,7 @@ class Vulnerability < ApplicationRecord include EachBatch include IgnorableColumns - ignore_column :milestone_id, remove_with: '16.9', remove_after: '2023-01-13' + ignore_column %i[epic_id milestone_id], remove_with: '16.9', remove_after: '2023-01-13' alias_attribute :vulnerability_id, :id diff --git a/ee/app/models/ee/vulnerability.rb b/ee/app/models/ee/vulnerability.rb index 7ff27fb2e00733..177bdf97749b02 100644 --- a/ee/app/models/ee/vulnerability.rb +++ b/ee/app/models/ee/vulnerability.rb @@ -35,8 +35,6 @@ module Vulnerability redact_field :description belongs_to :project # keep this association named 'project' for correct work of markdown cache - belongs_to :epic - belongs_to :author, class_name: 'User' # keep this association named 'author' for correct work of markdown cache belongs_to :updated_by, class_name: 'User' belongs_to :last_edited_by, class_name: 'User' diff --git a/ee/spec/models/ee/vulnerability_spec.rb b/ee/spec/models/ee/vulnerability_spec.rb index 8793f1394d5ccb..b0227b01d424d8 100644 --- a/ee/spec/models/ee/vulnerability_spec.rb +++ b/ee/spec/models/ee/vulnerability_spec.rb @@ -48,7 +48,6 @@ subject { build(:vulnerability) } it { is_expected.to belong_to(:project) } - it { is_expected.to belong_to(:epic) } it { is_expected.to have_many(:findings).class_name('Vulnerabilities::Finding').inverse_of(:vulnerability) } it { is_expected.to have_many(:dismissed_findings).class_name('Vulnerabilities::Finding').inverse_of(:vulnerability) } it { is_expected.to have_many(:merge_request_links).class_name('Vulnerabilities::MergeRequestLink').inverse_of(:vulnerability) } -- GitLab