Commit 4cfccc11 authored by Andreas Brandl's avatar Andreas Brandl

Adjust condition for partial index

https://gitlab.com/gitlab-org/gitlab/-/issues/219094
parent db5d4783
---
title: Adjust condition for partial indexes on services table
merge_request: 33044
author:
type: performance
# frozen_string_literal: true
class ChangePartialIndexesOnServices < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :services, [:type, :instance], unique: true, where: 'instance = true', name: 'index_services_on_type_and_instance_partial'
remove_concurrent_index_by_name :services, 'index_services_on_type_and_instance'
add_concurrent_index :services, [:type, :template], unique: true, where: 'template = true', name: 'index_services_on_type_and_template_partial'
remove_concurrent_index_by_name :services, 'index_services_on_type_and_template'
end
def down
add_concurrent_index :services, [:type, :instance], unique: true, where: 'instance IS TRUE', name: 'index_services_on_type_and_instance'
remove_concurrent_index_by_name :services, 'index_services_on_type_and_instance_partial'
add_concurrent_index :services, [:type, :template], unique: true, where: 'template IS TRUE', name: 'index_services_on_type_and_template'
remove_concurrent_index_by_name :services, 'index_services_on_type_and_template_partial'
end
end
......@@ -10647,9 +10647,9 @@ CREATE INDEX index_services_on_type ON public.services USING btree (type);
CREATE INDEX index_services_on_type_and_id_and_template_when_active ON public.services USING btree (type, id, template) WHERE (active = true);
CREATE UNIQUE INDEX index_services_on_type_and_instance ON public.services USING btree (type, instance) WHERE (instance IS TRUE);
CREATE UNIQUE INDEX index_services_on_type_and_instance_partial ON public.services USING btree (type, instance) WHERE (instance = true);
CREATE UNIQUE INDEX index_services_on_type_and_template ON public.services USING btree (type, template) WHERE (template IS TRUE);
CREATE UNIQUE INDEX index_services_on_type_and_template_partial ON public.services USING btree (type, template) WHERE (template = true);
CREATE UNIQUE INDEX index_shards_on_name ON public.shards USING btree (name);
......@@ -13934,5 +13934,6 @@ COPY "schema_migrations" (version) FROM STDIN;
20200519171058
20200525114553
20200525121014
20200526120714
\.
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