From 3da35b4a7a95fd804f68c733d413373579e13a9d Mon Sep 17 00:00:00 2001 From: Michael Becker <11881043-wandering_person@users.noreply.gitlab.com> Date: Thu, 16 Nov 2023 12:46:11 +0700 Subject: [PATCH] Ignore `start_date` column on `vulnerabilities` table `start_date` is always `nil` in production: ```sh [ gstg ] production> Vulnerability.where.not(start_date: 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-MR 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 | 4 +++- doc/api/project_vulnerabilities.md | 3 +-- doc/api/vulnerabilities.md | 6 +----- ee/lib/ee/api/entities/vulnerability.rb | 4 ++-- ee/spec/lib/ee/api/entities/vulnerability_spec.rb | 1 - 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/models/vulnerability.rb b/app/models/vulnerability.rb index a9e1b2dbc5b34e..702e7fce567e7f 100644 --- a/app/models/vulnerability.rb +++ b/app/models/vulnerability.rb @@ -5,7 +5,9 @@ class Vulnerability < ApplicationRecord include EachBatch include IgnorableColumns - ignore_column %i[epic_id milestone_id last_edited_at], remove_with: '16.9', remove_after: '2023-01-13' + ignore_column %i[epic_id milestone_id last_edited_at start_date], + remove_with: '16.9', + remove_after: '2024-01-13' alias_attribute :vulnerability_id, :id diff --git a/doc/api/project_vulnerabilities.md b/doc/api/project_vulnerabilities.md index 1fbea66de7f249..c15a74522195a3 100644 --- a/doc/api/project_vulnerabilities.md +++ b/doc/api/project_vulnerabilities.md @@ -9,6 +9,7 @@ type: reference, api > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/10242) in GitLab 12.6. > - `last_edited_at` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. +> - `start_date` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. WARNING: This API is in the process of being deprecated and considered unstable. @@ -96,7 +97,6 @@ Example response: "resolved_by_id": null, "resolved_on_default_branch": false, "severity": "low", - "start_date": null, "state": "detected", "title": "Regular Expression Denial of Service in debug", "updated_at": "2020-04-07T14:01:04.655Z", @@ -183,7 +183,6 @@ Example response: "resolved_by_id": null, "resolved_on_default_branch": false, "severity": "low", - "start_date": null, "state": "detected", "title": "Regular Expression Denial of Service in debug", "updated_at": "2020-04-07T14:01:04.655Z", diff --git a/doc/api/vulnerabilities.md b/doc/api/vulnerabilities.md index ff45c5d6cfa85e..bddedb05c2c642 100644 --- a/doc/api/vulnerabilities.md +++ b/doc/api/vulnerabilities.md @@ -8,6 +8,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/10242) in GitLab 12.6. > - `last_edited_at` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. +> - `start_date` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. NOTE: The former Vulnerabilities API was renamed to Vulnerability Findings API @@ -64,7 +65,6 @@ Example response: "updated_by_id": null, "last_edited_by_id": null, "closed_by_id": null, - "start_date": null, "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", @@ -113,7 +113,6 @@ Example response: "updated_by_id": null, "last_edited_by_id": null, "closed_by_id": null, - "start_date": null, "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", @@ -162,7 +161,6 @@ Example response: "updated_by_id": null, "last_edited_by_id": null, "closed_by_id": null, - "start_date": null, "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", @@ -211,7 +209,6 @@ Example response: "updated_by_id": null, "last_edited_by_id": null, "closed_by_id": null, - "start_date": null, "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", @@ -260,7 +257,6 @@ Example response: "updated_by_id": null, "last_edited_by_id": null, "closed_by_id": null, - "start_date": null, "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", diff --git a/ee/lib/ee/api/entities/vulnerability.rb b/ee/lib/ee/api/entities/vulnerability.rb index c0571bb4bd1b16..313d402ce09db3 100644 --- a/ee/lib/ee/api/entities/vulnerability.rb +++ b/ee/lib/ee/api/entities/vulnerability.rb @@ -26,7 +26,6 @@ class Vulnerability < Grape::Entity expose :dismissed_by_id expose :confirmed_by_id - expose :start_date expose :due_date expose :created_at @@ -35,9 +34,10 @@ class Vulnerability < Grape::Entity expose :dismissed_at expose :confirmed_at - # This field is deprecated and always returns nil + # These fields are deprecated and always returns nil # TODO remove with https://gitlab.com/gitlab-org/gitlab/-/work_items/431990 expose(:last_edited_at) { |_settings, _options| nil } + expose(:start_date) { |_settings, _options| nil } end end end diff --git a/ee/spec/lib/ee/api/entities/vulnerability_spec.rb b/ee/spec/lib/ee/api/entities/vulnerability_spec.rb index e96cdbeee4ad64..c11623ba2da52c 100644 --- a/ee/spec/lib/ee/api/entities/vulnerability_spec.rb +++ b/ee/spec/lib/ee/api/entities/vulnerability_spec.rb @@ -36,7 +36,6 @@ expect(subject[:dismissed_by_id]).to eq(vulnerability.dismissed_by_id) expect(subject[:confirmed_by_id]).to eq(vulnerability.confirmed_by_id) - expect(subject[:start_date]).to eq(vulnerability.start_date) expect(subject[:due_date]).to eq(vulnerability.due_date) expect(subject[:created_at]).to eq(vulnerability.created_at) -- GitLab