Commit db628d9d authored by Alexandru Croitor's avatar Alexandru Croitor

Replace namespaces unique index on name and parent_id

This replaces the unique index on name and parent_id in
namespaces table with an unique index on name, parent_id
and type. We need this index change in order to cover name
uniqueness across namespaces of type Group and also allow
the possibility to have one namespace of type ProjectNamespace
with the same name as a Group to maintain current functionality
parity between namespaces and projects.

https://gitlab.com/gitlab-org/gitlab/-/issues/341814

Changelog: changed
parent 708ffb4e
# frozen_string_literal: true
class AddUniqueNamespacesIndexOnNameParentIdAndType < Gitlab::Database::Migration[1.0]
INDEX_NAME = 'index_namespaces_name_parent_id_type'
disable_ddl_transaction!
def up
add_concurrent_index :namespaces, [:name, :parent_id, :type], unique: true, name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :namespaces, INDEX_NAME
end
end
# frozen_string_literal: true
class DropUniqueNamespacesIndexOnNameAndParentId < Gitlab::Database::Migration[1.0]
INDEX_NAME = 'index_namespaces_on_name_and_parent_id'
disable_ddl_transaction!
def up
remove_concurrent_index_by_name :namespaces, INDEX_NAME
end
def down
add_concurrent_index :namespaces, [:name, :parent_id], unique: true, name: INDEX_NAME
end
end
c50ccd9986188356776c2d19c5544a6da6e31b5bb1b16ed259455604cb6fd862
\ No newline at end of file
083b18b8e687ae8ff9d93ee77c6d4fc2916a2f1b77acf44132f216236b0ff06c
\ No newline at end of file
......@@ -25678,6 +25678,8 @@ CREATE INDEX index_namespaces_id_parent_id_is_not_null ON namespaces USING btree
CREATE INDEX index_namespaces_id_parent_id_is_null ON namespaces USING btree (id) WHERE (parent_id IS NULL);
CREATE UNIQUE INDEX index_namespaces_name_parent_id_type ON namespaces USING btree (name, parent_id, type);
CREATE INDEX index_namespaces_on_created_at ON namespaces USING btree (created_at);
CREATE INDEX index_namespaces_on_custom_project_templates_group_id_and_type ON namespaces USING btree (custom_project_templates_group_id, type) WHERE (custom_project_templates_group_id IS NOT NULL);
......@@ -25688,8 +25690,6 @@ CREATE INDEX index_namespaces_on_ldap_sync_last_successful_update_at ON namespac
CREATE INDEX index_namespaces_on_ldap_sync_last_update_at ON namespaces USING btree (ldap_sync_last_update_at);
CREATE UNIQUE INDEX index_namespaces_on_name_and_parent_id ON namespaces USING btree (name, parent_id);
CREATE INDEX index_namespaces_on_name_trigram ON namespaces USING gin (name gin_trgm_ops);
CREATE INDEX index_namespaces_on_owner_id ON namespaces USING btree (owner_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