Commit 835763c2 authored by Alper Akgun's avatar Alper Akgun

Merge branch 'sk/335326-add-cluster-id' into 'master'

Add cluster_agent_id to vulnerability_reads

See merge request gitlab-org/gitlab!76943
parents c2abc3bc 0adf1309
# frozen_string_literal: true
class AddClusterAgentIdToVulnerabilityReads < Gitlab::Database::Migration[1.0]
# rubocop:disable Migration/AddLimitToTextColumns
# limit is added in 20211216134134_add_text_limit_to_vulnerability_reads_cluster_agent_id.rb
def change
add_column :vulnerability_reads, :cluster_agent_id, :text
end
# rubocop:enable Migration/AddLimitToTextColumns
end
# frozen_string_literal: true
class AddTextLimitToVulnerabilityReadsClusterAgentId < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
add_text_limit :vulnerability_reads, :cluster_agent_id, 10
end
def down
remove_text_limit :vulnerability_reads, :cluster_agent_id
end
end
# frozen_string_literal: true
class AddIndexToClusterAgentId < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = "index_vulnerability_reads_on_cluster_agent_id"
CLUSTER_IMAGE_SCANNING_REPORT_TYPE = 7
def up
add_concurrent_index :vulnerability_reads, :cluster_agent_id, where: "report_type = #{CLUSTER_IMAGE_SCANNING_REPORT_TYPE}", name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME
end
end
a0c3a9746250aa67ffa8d05486fb6997c8d839b8bce7e870c0415c25600c5434
\ No newline at end of file
c53a1e4405187620929b8fc6877786cb713d13218f7385d1b9b3daaf6072fa05
\ No newline at end of file
9b733363587957b4044bc6806dfbb9632ec7f5f6ffc8c82280e025012b8acb5a
\ No newline at end of file
......@@ -20893,7 +20893,9 @@ CREATE TABLE vulnerability_reads (
resolved_on_default_branch boolean DEFAULT false NOT NULL,
uuid uuid NOT NULL,
location_image text,
CONSTRAINT check_380451bdbe CHECK ((char_length(location_image) <= 2048))
cluster_agent_id text,
CONSTRAINT check_380451bdbe CHECK ((char_length(location_image) <= 2048)),
CONSTRAINT check_a105eb825a CHECK ((char_length(cluster_agent_id) <= 10))
);
CREATE SEQUENCE vulnerability_reads_id_seq
......@@ -27878,6 +27880,8 @@ CREATE UNIQUE INDEX index_vulnerability_occurrences_on_uuid ON vulnerability_occ
CREATE INDEX index_vulnerability_occurrences_on_vulnerability_id ON vulnerability_occurrences USING btree (vulnerability_id);
CREATE INDEX index_vulnerability_reads_on_cluster_agent_id ON vulnerability_reads USING btree (cluster_agent_id) WHERE (report_type = 7);
CREATE INDEX index_vulnerability_reads_on_location_image ON vulnerability_reads USING btree (location_image) WHERE (report_type = ANY (ARRAY[2, 7]));
CREATE INDEX index_vulnerability_reads_on_scanner_id ON vulnerability_reads USING btree (scanner_id);
......@@ -88,7 +88,8 @@ RSpec.describe 'Database schema' do
users_star_projects: %w[user_id],
vulnerability_identifiers: %w[external_id],
vulnerability_scanners: %w[external_id],
security_scans: %w[pipeline_id] # foreign key is not added as ci_pipeline table will be moved into different db soon
security_scans: %w[pipeline_id], # foreign key is not added as ci_pipeline table will be moved into different db soon
vulnerability_reads: %w[cluster_agent_id]
}.with_indifferent_access.freeze
context 'for table' do
......
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