diff --git a/db/post_migrate/20231219125907_remove_updated_by_id_column_from_vulnerabilities.rb b/db/post_migrate/20231219125907_remove_updated_by_id_column_from_vulnerabilities.rb new file mode 100644 index 0000000000000000000000000000000000000000..ecac9b55f4c38a7dac796536da2e502231e2e81b --- /dev/null +++ b/db/post_migrate/20231219125907_remove_updated_by_id_column_from_vulnerabilities.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class RemoveUpdatedByIdColumnFromVulnerabilities < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.8' + + def up + with_lock_retries do + remove_column :vulnerabilities, :updated_by_id + end + end + + def down + add_column :vulnerabilities, :updated_by_id, :bigint unless column_exists?(:vulnerabilities, :updated_by_id) + + # Add back index and constraint that were dropped in `up` + add_concurrent_index(:vulnerabilities, :updated_by_id) + add_concurrent_foreign_key(:vulnerabilities, :users, column: :updated_by_id, on_delete: :nullify) + end +end diff --git a/db/schema_migrations/20231219125907 b/db/schema_migrations/20231219125907 new file mode 100644 index 0000000000000000000000000000000000000000..e1b21ac65de4e3bf694a9ee3af383ff84e730192 --- /dev/null +++ b/db/schema_migrations/20231219125907 @@ -0,0 +1 @@ +91251dddd4dd52f79f48560f6fe81cb52bb30103c1a1441d772c771e853a7f06 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 060f044fe00a0609b6d5a490df8d9f7ff96a964f..eb53d77ff87c54d47776c15bf25e0f0e3c8255cd 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -24911,7 +24911,6 @@ CREATE TABLE vulnerabilities ( epic_id bigint, project_id bigint NOT NULL, author_id bigint NOT NULL, - updated_by_id bigint, start_date date, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, @@ -35177,8 +35176,6 @@ CREATE INDEX index_vulnerabilities_on_project_id_and_state_and_severity ON vulne CREATE INDEX index_vulnerabilities_on_resolved_by_id ON vulnerabilities USING btree (resolved_by_id); -CREATE INDEX index_vulnerabilities_on_updated_by_id ON vulnerabilities USING btree (updated_by_id); - CREATE INDEX index_vulnerabilities_project_id_and_id_on_default_branch ON vulnerabilities USING btree (project_id, id) WHERE (present_on_default_branch IS TRUE); CREATE INDEX index_vulnerabilities_project_id_state_severity_default_branch ON vulnerabilities USING btree (project_id, state, severity, present_on_default_branch); @@ -37862,9 +37859,6 @@ ALTER TABLE ONLY protected_branches ALTER TABLE ONLY scan_result_policies ADD CONSTRAINT fk_7aa24439f1 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerabilities - ADD CONSTRAINT fk_7ac31eacb9 FOREIGN KEY (updated_by_id) REFERENCES users(id) ON DELETE SET NULL; - ALTER TABLE ONLY catalog_resource_versions ADD CONSTRAINT fk_7ad8849db4 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; diff --git a/ee/spec/models/ee/vulnerability_spec.rb b/ee/spec/models/ee/vulnerability_spec.rb index 8ee1a80787cbd09105cc83f6753284a3eca00c53..26b34b829d20175bc63a6301c8429d93a9f040ef 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('af31520c7b44d816a185881ad7ca05728b8da3a3b0c5f55ca00b9c047e6e066f').reference('https://gitlab.com/gitlab-org/gitlab/-/issues/349315') } + it { is_expected.to have_locked_schema('b1278ab481678e3a0962433517923c9a81d451c8e4b1fc85aaa080f5e5924330').reference('https://gitlab.com/gitlab-org/gitlab/-/issues/349315') } it_behaves_like 'vulnerability and finding shared examples' do let(:transformer_method) { :itself }