From 1726baba47baaa0529a642085d5b31f4187887ad Mon Sep 17 00:00:00 2001 From: Michael Becker <11881043-wandering_person@users.noreply.gitlab.com> Date: Thu, 16 Nov 2023 14:42:15 +0700 Subject: [PATCH] Ignore `due_date` column on `vulnerabilities` table `due_date` is always `nil` in production: ```sh [ gstg ] production> Vulnerability.where.not(due_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 | 2 +- doc/api/project_vulnerabilities.md | 3 +-- doc/api/vulnerabilities.md | 6 +----- ee/lib/ee/api/entities/vulnerability.rb | 3 +-- ee/spec/lib/ee/api/entities/vulnerability_spec.rb | 5 ++--- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/app/models/vulnerability.rb b/app/models/vulnerability.rb index da607dcb7718cc..6bf63bab82c19f 100644 --- a/app/models/vulnerability.rb +++ b/app/models/vulnerability.rb @@ -5,7 +5,7 @@ class Vulnerability < ApplicationRecord include EachBatch include IgnorableColumns - ignore_column %i[epic_id milestone_id last_edited_at last_edited_by_id + ignore_column %i[due_date epic_id milestone_id last_edited_at last_edited_by_id start_date start_date_sourcing_milestone_id updated_by_id], remove_with: '16.9', remove_after: '2024-01-19' diff --git a/doc/api/project_vulnerabilities.md b/doc/api/project_vulnerabilities.md index c3f03d0a073c36..677ec2afc84c8a 100644 --- a/doc/api/project_vulnerabilities.md +++ b/doc/api/project_vulnerabilities.md @@ -12,6 +12,7 @@ type: reference, api > - `start_date` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. > - `updated_by_id` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. > - `last_edited_by_id` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. +> - `due_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. @@ -63,7 +64,6 @@ Example response: "description": null, "dismissed_at": null, "dismissed_by_id": null, - "due_date": null, "finding": { "confidence": "medium", "created_at": "2020-04-07T14:01:04.630Z", @@ -147,7 +147,6 @@ Example response: "description": null, "dismissed_at": null, "dismissed_by_id": null, - "due_date": null, "finding": { "confidence": "medium", "created_at": "2020-04-07T14:01:04.630Z", diff --git a/doc/api/vulnerabilities.md b/doc/api/vulnerabilities.md index 4820eb89e0d988..8dd41e7a6d12b9 100644 --- a/doc/api/vulnerabilities.md +++ b/doc/api/vulnerabilities.md @@ -11,6 +11,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w > - `start_date` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. > - `updated_by_id` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. > - `last_edited_by_id` [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/268154) in GitLab 16.7. +> - `due_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 @@ -65,7 +66,6 @@ Example response: }, "author_id": 1, "closed_by_id": null, - "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", "closed_at": null @@ -111,7 +111,6 @@ Example response: }, "author_id": 1, "closed_by_id": null, - "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", "closed_at": null @@ -157,7 +156,6 @@ Example response: }, "author_id": 1, "closed_by_id": null, - "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", "closed_at": null @@ -203,7 +201,6 @@ Example response: }, "author_id": 1, "closed_by_id": null, - "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", "closed_at": null @@ -249,7 +246,6 @@ Example response: }, "author_id": 1, "closed_by_id": null, - "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", "closed_at": null diff --git a/ee/lib/ee/api/entities/vulnerability.rb b/ee/lib/ee/api/entities/vulnerability.rb index 752741fa4d4efd..a4f5b5f7fe10fc 100644 --- a/ee/lib/ee/api/entities/vulnerability.rb +++ b/ee/lib/ee/api/entities/vulnerability.rb @@ -24,8 +24,6 @@ class Vulnerability < Grape::Entity expose :dismissed_by_id expose :confirmed_by_id - expose :due_date - expose :created_at expose :updated_at expose :resolved_at @@ -38,6 +36,7 @@ class Vulnerability < Grape::Entity expose(:start_date) { |_settings, _options| nil } expose(:updated_by_id) { |_settings, _options| nil } expose(:last_edited_by_id) { |_settings, _options| nil } + expose(:due_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 826272f9e65b20..7024e4988ffcab 100644 --- a/ee/spec/lib/ee/api/entities/vulnerability_spec.rb +++ b/ee/spec/lib/ee/api/entities/vulnerability_spec.rb @@ -34,8 +34,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[:due_date]).to eq(vulnerability.due_date) - expect(subject[:created_at]).to eq(vulnerability.created_at) expect(subject[:updated_at]).to eq(vulnerability.updated_at) expect(subject[:resolved_at]).to eq(vulnerability.resolved_at) @@ -44,10 +42,11 @@ # These fields are deprecated and always returns nil # TODO remove with https://gitlab.com/gitlab-org/gitlab/-/work_items/431990 - deprecated_fields = subject.to_h.slice(*%i[last_edited_at start_date updated_by_id last_edited_by_id]) + deprecated_fields = subject.to_h.slice(*%i[due_date last_edited_at start_date updated_by_id last_edited_by_id]) expect(deprecated_fields).to eq( last_edited_at: nil, start_date: nil, + due_date: nil, updated_by_id: nil, last_edited_by_id: nil ) -- GitLab