Commit 14375f8b authored by Mike Kozono's avatar Mike Kozono

Validate not null external_diff_store

Add remove an index which was added only to facilitate populating NULL
values.
parent cac12b17
---
title: Validate not null external_diff_store field on merge_request_diffs to maintain
data integrity
merge_request: 42045
author:
type: added
# frozen_string_literal: true
class ValidateNotNullExternalDiffStoreOnMergeRequestDiffs < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Remove index which was only added to fill external_diff_store
INDEX_NAME = 'index_merge_request_diffs_external_diff_store_is_null'
DOWNTIME = false
disable_ddl_transaction!
def up
validate_not_null_constraint :merge_request_diffs, :external_diff_store
remove_concurrent_index_by_name :merge_request_diffs, INDEX_NAME
end
def down
add_concurrent_index :merge_request_diffs, :id, where: 'external_diff_store IS NULL', name: INDEX_NAME
end
end
904e0a8623df766a1f385bbb3db8942d10c4a92354d8f5e3bc03a813337c5fa1
\ No newline at end of file
......@@ -13216,7 +13216,8 @@ CREATE TABLE public.merge_request_diffs (
external_diff character varying,
external_diff_store integer DEFAULT 1,
stored_externally boolean,
files_count smallint
files_count smallint,
CONSTRAINT check_93ee616ac9 CHECK ((external_diff_store IS NOT NULL))
);
CREATE SEQUENCE public.merge_request_diffs_id_seq
......@@ -17941,9 +17942,6 @@ ALTER TABLE public.vulnerability_scanners
ALTER TABLE public.packages_package_files
ADD CONSTRAINT check_4c5e6bb0b3 CHECK ((file_store IS NOT NULL)) NOT VALID;
ALTER TABLE public.merge_request_diffs
ADD CONSTRAINT check_93ee616ac9 CHECK ((external_diff_store IS NOT NULL)) NOT VALID;
ALTER TABLE ONLY public.ci_build_needs
ADD CONSTRAINT ci_build_needs_pkey PRIMARY KEY (id);
......@@ -20262,8 +20260,6 @@ CREATE UNIQUE INDEX index_merge_request_diff_files_on_mr_diff_id_and_order ON pu
CREATE INDEX index_merge_request_diffs_by_id_partial ON public.merge_request_diffs USING btree (id) WHERE ((files_count > 0) AND ((NOT stored_externally) OR (stored_externally IS NULL)));
CREATE INDEX index_merge_request_diffs_external_diff_store_is_null ON public.merge_request_diffs USING btree (id) WHERE (external_diff_store IS NULL);
CREATE INDEX index_merge_request_diffs_on_external_diff_store ON public.merge_request_diffs USING btree (external_diff_store);
CREATE INDEX index_merge_request_diffs_on_merge_request_id_and_id ON public.merge_request_diffs USING btree (merge_request_id, id);
......
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