Commit bc3cf158 authored by Alex Kalderimis's avatar Alex Kalderimis

Replicate integrations indices for type_new

This recreates all the indices we use for type on type_new, so that
when we start using `type_new` we get identical performance and
consistency guarantees.

Changelog: changed
parent c5e61f2a
# frozen_string_literal: true
# Reproduce the indices on integrations.type on integrations.type_new
class CreateIndexesOnIntegrationTypeNew < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
TABLE_NAME = :integrations
COLUMN = :type_new
def indices
[
{
name: "index_integrations_on_project_and_#{COLUMN}_where_inherit_null",
columns: [:project_id, COLUMN],
where: 'inherit_from_id IS NULL'
},
{
name: "index_integrations_on_project_id_and_#{COLUMN}_unique",
columns: [:project_id, COLUMN],
unique: true
},
{
name: "index_integrations_on_#{COLUMN}",
columns: [COLUMN]
},
{
name: "index_integrations_on_#{COLUMN}_and_instance_partial",
columns: [COLUMN, :instance],
where: 'instance = true'
},
{
name: "index_integrations_on_#{COLUMN}_and_template_partial",
columns: [COLUMN, :template],
where: 'template = true'
},
{
# column names are limited to 63 characters, so this one is re-worded for clarity
name: "index_integrations_on_#{COLUMN}_id_when_active_and_has_project",
columns: [COLUMN, :id],
where: '((active = true) AND (project_id IS NOT NULL))'
},
{
name: "index_integrations_on_unique_group_id_and_#{COLUMN}",
columns: [:group_id, COLUMN]
}
]
end
def up
indices.each do |index|
add_concurrent_index TABLE_NAME, index[:columns], index.except(:columns)
end
end
def down
indices.each do |index|
remove_concurrent_index_by_name TABLE_NAME, index[:name]
end
end
end
9ce8aa469b9469d25fbba52147e24c95f6242c2ab1e114df8baaf5a45268d2fd
\ No newline at end of file
......@@ -26639,8 +26639,12 @@ CREATE INDEX index_insights_on_project_id ON insights USING btree (project_id);
CREATE INDEX index_integrations_on_inherit_from_id ON integrations USING btree (inherit_from_id);
CREATE INDEX index_integrations_on_project_and_type_new_where_inherit_null ON integrations USING btree (project_id, type_new) WHERE (inherit_from_id IS NULL);
CREATE INDEX index_integrations_on_project_and_type_where_inherit_null ON integrations USING btree (project_id, type) WHERE (inherit_from_id IS NULL);
CREATE UNIQUE INDEX index_integrations_on_project_id_and_type_new_unique ON integrations USING btree (project_id, type_new);
CREATE UNIQUE INDEX index_integrations_on_project_id_and_type_unique ON integrations USING btree (project_id, type);
CREATE INDEX index_integrations_on_template ON integrations USING btree (template);
......@@ -26653,8 +26657,18 @@ CREATE UNIQUE INDEX index_integrations_on_type_and_template_partial ON integrati
CREATE INDEX index_integrations_on_type_id_when_active_and_project_id_not_nu ON integrations USING btree (type, id) WHERE ((active = true) AND (project_id IS NOT NULL));
CREATE INDEX index_integrations_on_type_new ON integrations USING btree (type_new);
CREATE INDEX index_integrations_on_type_new_and_instance_partial ON integrations USING btree (type_new, instance) WHERE (instance = true);
CREATE INDEX index_integrations_on_type_new_and_template_partial ON integrations USING btree (type_new, template) WHERE (template = true);
CREATE INDEX index_integrations_on_type_new_id_when_active_and_has_project ON integrations USING btree (type_new, id) WHERE ((active = true) AND (project_id IS NOT NULL));
CREATE UNIQUE INDEX index_integrations_on_unique_group_id_and_type ON integrations USING btree (group_id, type);
CREATE INDEX index_integrations_on_unique_group_id_and_type_new ON integrations USING btree (group_id, type_new);
CREATE INDEX index_internal_ids_on_namespace_id ON internal_ids USING btree (namespace_id);
CREATE INDEX index_internal_ids_on_project_id ON internal_ids USING btree (project_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