diff options
Diffstat (limited to 'db/post_migrate/20220316112206_add_contacts_index_on_group_email_and_id.rb')
-rw-r--r-- | db/post_migrate/20220316112206_add_contacts_index_on_group_email_and_id.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/db/post_migrate/20220316112206_add_contacts_index_on_group_email_and_id.rb b/db/post_migrate/20220316112206_add_contacts_index_on_group_email_and_id.rb new file mode 100644 index 00000000000..21434a80314 --- /dev/null +++ b/db/post_migrate/20220316112206_add_contacts_index_on_group_email_and_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddContactsIndexOnGroupEmailAndId < Gitlab::Database::Migration[1.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_customer_relations_contacts_on_unique_email_per_group' + + def up + add_concurrent_index :customer_relations_contacts, 'group_id, lower(email), id', name: INDEX_NAME, unique: true + end + + def down + remove_concurrent_index_by_name :customer_relations_contacts, INDEX_NAME + end +end |