From 97e8e24866f46b8a641de84749a95b63aab05b86 Mon Sep 17 00:00:00 2001 From: Michael Becker <11881043-wandering_person@users.noreply.gitlab.com> Date: Mon, 13 Nov 2023 12:23:33 +0700 Subject: [PATCH 1/2] Remove `milestone_id` field from `Vulnerabilities` milestone_id` is always `nil` in production: ```sh [ gstg ] production> Vulnerability.where.not(milestone_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 | 1 - ee/spec/models/ee/vulnerability_spec.rb | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/vulnerability.rb b/app/models/vulnerability.rb index 0e3fe2cc8ac664..fca21b073a02ad 100644 --- a/app/models/vulnerability.rb +++ b/app/models/vulnerability.rb @@ -5,6 +5,8 @@ class Vulnerability < ApplicationRecord include EachBatch include IgnorableColumns + ignore_column :milestone_id, remove_with: '16.9', remove_after: '2023-12-17' + alias_attribute :vulnerability_id, :id scope :with_projects, -> { includes(:project) } diff --git a/ee/app/models/ee/vulnerability.rb b/ee/app/models/ee/vulnerability.rb index ea10458137c686..7ff27fb2e00733 100644 --- a/ee/app/models/ee/vulnerability.rb +++ b/ee/app/models/ee/vulnerability.rb @@ -35,7 +35,6 @@ module Vulnerability redact_field :description belongs_to :project # keep this association named 'project' for correct work of markdown cache - belongs_to :milestone belongs_to :epic belongs_to :author, class_name: 'User' # keep this association named 'author' for correct work of markdown cache diff --git a/ee/spec/models/ee/vulnerability_spec.rb b/ee/spec/models/ee/vulnerability_spec.rb index 24bfe2779f3106..8793f1394d5ccb 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(:milestone) } 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) } -- GitLab From efba8006afe59ee8cab4b623464a8bec7687566d Mon Sep 17 00:00:00 2001 From: Michael Becker <11881043-wandering_person@users.noreply.gitlab.com> Date: Tue, 14 Nov 2023 12:31:07 +0700 Subject: [PATCH 2/2] Adjust `remove_after:` date Update to match beginning of `16.9` as found [here][c2-0] [c2-0]:https://gitlab.com/groups/gitlab-org/-/milestones/96 --- app/models/vulnerability.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/vulnerability.rb b/app/models/vulnerability.rb index fca21b073a02ad..abdf585af8123a 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-12-17' + ignore_column :milestone_id, remove_with: '16.9', remove_after: '2023-01-13' alias_attribute :vulnerability_id, :id -- GitLab