Commit fe8946ee authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '355703-add-index-to-vulnerabilities' into 'master'

Add index to improve speed of vulnerabilities

See merge request gitlab-org/gitlab!83028
parents d8b25e76 f43b9242
# frozen_string_literal: true
class AddIndexToVulnerabilities < Gitlab::Database::Migration[1.0]
INDEX_NAME = 'index_vulnerabilites_common_finder_query'
disable_ddl_transaction!
def up
add_concurrent_index(
:vulnerabilities,
%i[project_id state report_type severity id],
name: INDEX_NAME
)
end
def down
remove_concurrent_index_by_name(
:vulnerabilities,
INDEX_NAME
)
end
end
beeab3a2197f11a40049e983a5184ab9b80370c9867461239e12a5ce36b8f5e8
\ No newline at end of file
......@@ -29382,6 +29382,8 @@ CREATE UNIQUE INDEX index_vuln_historical_statistics_on_project_id_and_date ON v
CREATE INDEX index_vuln_reads_on_project_id_state_severity_and_vuln_id ON vulnerability_reads USING btree (project_id, state, severity, vulnerability_id DESC);
CREATE INDEX index_vulnerabilites_common_finder_query ON vulnerabilities USING btree (project_id, state, report_type, severity, id);
CREATE INDEX index_vulnerabilities_on_author_id ON vulnerabilities USING btree (author_id);
CREATE INDEX index_vulnerabilities_on_confirmed_by_id ON vulnerabilities USING btree (confirmed_by_id);
......@@ -29,7 +29,7 @@ RSpec.describe Vulnerability do
let_it_be(:vulnerability) { create(:vulnerability, :sast, :confirmed, :low, project: project) }
let_it_be(:finding) { create(:vulnerabilities_finding, vulnerability: vulnerability) }
it { is_expected.to have_locked_schema('1128736d19b1457375faecb3bf8017350431dbbca91222c8edfcfa7c649638fb').reference('https://gitlab.com/gitlab-org/gitlab/-/issues/349315') }
it { is_expected.to have_locked_schema('9dfcb7cb227f5880125b579d2848d78fbb82af0fa00eac00b0137c0da691bbc4').reference('https://gitlab.com/gitlab-org/gitlab/-/issues/349315') }
describe 'enums' do
it { is_expected.to define_enum_for(:state).with_values(state_values) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment