Commit d9987355 authored by Mehmet Emin INAC's avatar Mehmet Emin INAC

Add `latest_pipeline_id` column to `vulnerability_statistics` table

Changelog: added
parent 4592b03a
# frozen_string_literal: true
class AddLatestPipelineIdIntoVulnerabilityStatisticsTable < ActiveRecord::Migration[6.0]
def change
add_column :vulnerability_statistics, :latest_pipeline_id, :bigint
end
end
# frozen_string_literal: true
class AddIndexToVulnerabilityStatisticsOnLatestPipelineId < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
INDEX_NAME = 'index_vulnerability_statistics_on_latest_pipeline_id'
disable_ddl_transaction!
def up
add_concurrent_index :vulnerability_statistics, :latest_pipeline_id, name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :vulnerability_statistics, INDEX_NAME
end
end
# frozen_string_literal: true
class AddForeignKeyForLatestPipelineIdToCiPipelines < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
add_concurrent_foreign_key :vulnerability_statistics, :ci_pipelines, column: :latest_pipeline_id, on_delete: :nullify
end
def down
with_lock_retries do
remove_foreign_key_if_exists :vulnerability_statistics, :ci_pipelines
end
end
end
ae91ea7481ea21ce29b4c0697f77fd83017c36d913739ed67e5c907a48c56f69
\ No newline at end of file
e72471e63dc108939473232437eda4c718382630c1173ae20023002d382e5ffa
\ No newline at end of file
3c53d85bec154ec68a23841d37317d10fa6c7c846bc5f54f5b7876081105ac7b
\ No newline at end of file
......@@ -19247,7 +19247,8 @@ CREATE TABLE vulnerability_statistics (
low integer DEFAULT 0 NOT NULL,
unknown integer DEFAULT 0 NOT NULL,
info integer DEFAULT 0 NOT NULL,
letter_grade smallint NOT NULL
letter_grade smallint NOT NULL,
latest_pipeline_id bigint
);
CREATE SEQUENCE vulnerability_statistics_id_seq
......@@ -24863,6 +24864,8 @@ CREATE UNIQUE INDEX index_vulnerability_remediations_on_project_id_and_checksum
CREATE UNIQUE INDEX index_vulnerability_scanners_on_project_id_and_external_id ON vulnerability_scanners USING btree (project_id, external_id);
CREATE INDEX index_vulnerability_statistics_on_latest_pipeline_id ON vulnerability_statistics USING btree (latest_pipeline_id);
CREATE INDEX index_vulnerability_statistics_on_letter_grade ON vulnerability_statistics USING btree (letter_grade);
CREATE UNIQUE INDEX index_vulnerability_statistics_on_unique_project_id ON vulnerability_statistics USING btree (project_id);
......@@ -25964,6 +25967,9 @@ ALTER TABLE ONLY sprints
ALTER TABLE ONLY application_settings
ADD CONSTRAINT fk_e8a145f3a7 FOREIGN KEY (instance_administrators_group_id) REFERENCES namespaces(id) ON DELETE SET NULL;
ALTER TABLE ONLY vulnerability_statistics
ADD CONSTRAINT fk_e8b13c928f FOREIGN KEY (latest_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL;
ALTER TABLE ONLY ci_triggers
ADD CONSTRAINT fk_e8e10d1964 FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE;
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