From 636c4f93c58e20b2197701495bf3aa02085a87a5 Mon Sep 17 00:00:00 2001 From: Michael Becker <11881043-wandering_person@users.noreply.gitlab.com> Date: Thu, 16 Nov 2023 14:59:41 +0700 Subject: [PATCH] Ignore `last_edited_at` column on `vulnerabilities` table `last_edited_at` is always `nil` in production: ```sh [ gstg ] production> Vulnerability.where.not(last_edited_at: 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 | 5 ++--- doc/api/vulnerabilities.md | 8 ++------ ee/lib/ee/api/entities/vulnerability.rb | 5 ++++- ee/spec/lib/ee/api/entities/vulnerability_spec.rb | 1 - 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/models/vulnerability.rb b/app/models/vulnerability.rb index 1dff78354db5f1..a9e1b2dbc5b34e 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], remove_with: '16.9', remove_after: '2023-01-13' + ignore_column %i[epic_id milestone_id last_edited_at], remove_with: '16.9', remove_after: '2023-01-13' alias_attribute :vulnerability_id, :id diff --git a/doc/api/project_vulnerabilities.md b/doc/api/project_vulnerabilities.md index 2b4d3ec50dfd69..1fbea66de7f249 100644 --- a/doc/api/project_vulnerabilities.md +++ b/doc/api/project_vulnerabilities.md @@ -7,7 +7,8 @@ type: reference, api # Project Vulnerabilities API **(ULTIMATE ALL)** -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/10242) in GitLab 12.6. +> - [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. WARNING: This API is in the process of being deprecated and considered unstable. @@ -79,7 +80,6 @@ Example response: "vulnerability_id": 103 }, "id": 103, - "last_edited_at": null, "last_edited_by_id": null, "project": { "created_at": "2020-04-07T13:54:25.634Z", @@ -167,7 +167,6 @@ Example response: "vulnerability_id": 103 }, "id": 103, - "last_edited_at": null, "last_edited_by_id": null, "project": { "created_at": "2020-04-07T13:54:25.634Z", diff --git a/doc/api/vulnerabilities.md b/doc/api/vulnerabilities.md index dc5e5c5f509eb9..ff45c5d6cfa85e 100644 --- a/doc/api/vulnerabilities.md +++ b/doc/api/vulnerabilities.md @@ -6,7 +6,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w # Vulnerabilities API **(ULTIMATE ALL)** -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/10242) in GitLab 12.6. +> - [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. NOTE: The former Vulnerabilities API was renamed to Vulnerability Findings API @@ -67,7 +68,6 @@ Example response: "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", - "last_edited_at": null, "closed_at": null } ``` @@ -117,7 +117,6 @@ Example response: "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", - "last_edited_at": null, "closed_at": null } ``` @@ -167,7 +166,6 @@ Example response: "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", - "last_edited_at": null, "closed_at": null } ``` @@ -217,7 +215,6 @@ Example response: "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", - "last_edited_at": null, "closed_at": null } ``` @@ -267,7 +264,6 @@ Example response: "due_date": null, "created_at": "2019-10-13T15:08:40.219Z", "updated_at": "2019-10-13T15:09:40.382Z", - "last_edited_at": null, "closed_at": null } ``` diff --git a/ee/lib/ee/api/entities/vulnerability.rb b/ee/lib/ee/api/entities/vulnerability.rb index 504834cf353498..c0571bb4bd1b16 100644 --- a/ee/lib/ee/api/entities/vulnerability.rb +++ b/ee/lib/ee/api/entities/vulnerability.rb @@ -31,10 +31,13 @@ class Vulnerability < Grape::Entity expose :created_at expose :updated_at - expose :last_edited_at expose :resolved_at expose :dismissed_at expose :confirmed_at + + # This field is deprecated and always returns nil + # TODO remove with https://gitlab.com/gitlab-org/gitlab/-/work_items/431990 + expose(:last_edited_at) { |_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 e712f517eeafe9..e96cdbeee4ad64 100644 --- a/ee/spec/lib/ee/api/entities/vulnerability_spec.rb +++ b/ee/spec/lib/ee/api/entities/vulnerability_spec.rb @@ -41,7 +41,6 @@ expect(subject[:created_at]).to eq(vulnerability.created_at) expect(subject[:updated_at]).to eq(vulnerability.updated_at) - expect(subject[:last_edited_at]).to eq(vulnerability.last_edited_at) expect(subject[:resolved_at]).to eq(vulnerability.resolved_at) expect(subject[:dismissed_at]).to eq(vulnerability.dismissed_at) expect(subject[:confirmed_at]).to eq(vulnerability.confirmed_at) -- GitLab