Commit 2c1f5be1 authored by Tiger Watson's avatar Tiger Watson

Merge branch 'mk/part-1-enforce-not-null-external-diff-store-on-mr-diffs' into 'master'

Geo: Part 1 of Enforce not null merge_request_diffs.external_diff_store

See merge request gitlab-org/gitlab!38549
parents 95af3936 2dc958bc
---
title: Add database migrations to prepare for future Geo replication
merge_request: 38549
author:
type: changed
# frozen_string_literal: true
class AddDefaultValueForExternalDiffStoreToMergeRequestDiffs < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
change_column_default :merge_request_diffs, :external_diff_store, 1
end
end
def down
with_lock_retries do
change_column_default :merge_request_diffs, :external_diff_store, nil
end
end
end
# frozen_string_literal: true
class AddPartialIndexOnIdToMergeRequestDiffs < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_merge_request_diffs_external_diff_store_is_null'
disable_ddl_transaction!
def up
add_concurrent_index :merge_request_diffs, :id, where: 'external_diff_store IS NULL', name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :merge_request_diffs, INDEX_NAME
end
end
# frozen_string_literal: true
class AddNotNullConstraintOnExternalDiffStoreToMergeRequestDiffs < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_not_null_constraint(:merge_request_diffs, :external_diff_store, validate: false)
end
def down
remove_not_null_constraint(:merge_request_diffs, :external_diff_store)
end
end
f1e2f11710ca7175b7a77b0f52bd204403dfcfd0b6b33cd00e3fa0d020be1287
\ No newline at end of file
ac65340525eba0cd025be706dde4deaf4574f8a7ffb9531d56ffae707e7e8b6d
\ No newline at end of file
3177e2f9549add35789e64b14c5958c4fb42fdce4b4705505bc9bbe326d9a875
\ No newline at end of file
......@@ -13003,7 +13003,7 @@ CREATE TABLE public.merge_request_diffs (
start_commit_sha character varying,
commits_count integer,
external_diff character varying,
external_diff_store integer,
external_diff_store integer DEFAULT 1,
stored_externally boolean
);
......@@ -17614,6 +17614,9 @@ ALTER TABLE public.design_management_designs
ALTER TABLE public.vulnerability_scanners
ADD CONSTRAINT check_37608c9db5 CHECK ((char_length(vendor) <= 255)) 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);
......@@ -19850,6 +19853,8 @@ CREATE INDEX index_merge_request_diff_commits_on_sha ON public.merge_request_dif
CREATE UNIQUE INDEX index_merge_request_diff_files_on_mr_diff_id_and_order ON public.merge_request_diff_files USING btree (merge_request_diff_id, relative_order);
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