From 367f6734775ad55cc6cc250578c5feae6b4a026a Mon Sep 17 00:00:00 2001 From: Michael Becker <11881043-wandering_person@users.noreply.gitlab.com> Date: Wed, 13 Dec 2023 20:32:02 +0700 Subject: [PATCH] Drop `last_edited_at` Column From Vulnerabilities `last_edited_at` is an ignored column ([source][0]) This commit drops the column for step 2 of the [3-MR drop column process][1] Using the command `\d+ vulnerabilities` on [postgres.ai][2] indicates **there are NOT indexes and constraints** Related to https://gitlab.com/gitlab-org/gitlab/-/issues/268154 [0]:https://gitlab.com/gitlab-org/gitlab/-/blob/0ef7ab245a0952c68232b3a3418b673b912b5115/app/models/vulnerability.rb#L8-11 [1]:https://docs.gitlab.com/ee/development/database/avoiding_downtime_in_migrations.html#the-removed-column-has-no-indexes-or-constraints-that-belong-to-it [2]:https://console.postgres.ai Changelog: removed --- ..._last_edited_at_column_from_vulnerabilities.rb | 15 +++++++++++++++ db/schema_migrations/20231220130725 | 1 + db/structure.sql | 1 - ee/spec/models/ee/vulnerability_spec.rb | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 db/post_migrate/20231220130725_remove_last_edited_at_column_from_vulnerabilities.rb create mode 100644 db/schema_migrations/20231220130725 diff --git a/db/post_migrate/20231220130725_remove_last_edited_at_column_from_vulnerabilities.rb b/db/post_migrate/20231220130725_remove_last_edited_at_column_from_vulnerabilities.rb new file mode 100644 index 00000000000000..e3e963ee0c0c95 --- /dev/null +++ b/db/post_migrate/20231220130725_remove_last_edited_at_column_from_vulnerabilities.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveLastEditedAtColumnFromVulnerabilities < Gitlab::Database::Migration[2.2] + milestone '16.8' + + enable_lock_retries! + + def up + remove_column :vulnerabilities, :last_edited_at + end + + def down + add_column :vulnerabilities, :last_edited_at, :datetime_with_timezone + end +end diff --git a/db/schema_migrations/20231220130725 b/db/schema_migrations/20231220130725 new file mode 100644 index 00000000000000..85a0fbfc47d22d --- /dev/null +++ b/db/schema_migrations/20231220130725 @@ -0,0 +1 @@ +a331c4c68080c60637b361b1778d840c367e1fe3dd1d588476a8a00fb5001389 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 77723578965a60..f28d7cf6266fbd 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -24898,7 +24898,6 @@ CREATE TABLE vulnerabilities ( updated_by_id bigint, last_edited_by_id bigint, start_date date, - last_edited_at timestamp with time zone, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, title character varying(255) NOT NULL, diff --git a/ee/spec/models/ee/vulnerability_spec.rb b/ee/spec/models/ee/vulnerability_spec.rb index aef6efd4799901..6330ba9e7a5f47 100644 --- a/ee/spec/models/ee/vulnerability_spec.rb +++ b/ee/spec/models/ee/vulnerability_spec.rb @@ -29,7 +29,7 @@ let_it_be(:vulnerability) { create(:vulnerability, :sast, :confirmed, :low, :with_state_transition, project: project) } let_it_be(:finding) { create(:vulnerabilities_finding, vulnerability: vulnerability) } - it { is_expected.to have_locked_schema('aeb78a130abaae6d526c87dc265c987b23074746d7fb1912de7e6969e93090d1').reference('https://gitlab.com/gitlab-org/gitlab/-/issues/349315') } + it { is_expected.to have_locked_schema('cb13c5ef1e2f527aa7af69b2d8613551b6ec048628f4c10f65217657454b0bbb').reference('https://gitlab.com/gitlab-org/gitlab/-/issues/349315') } it_behaves_like 'vulnerability and finding shared examples' do let(:transformer_method) { :itself } -- GitLab