summaryrefslogtreecommitdiff
path: root/db/migrate/20220408001450_add_work_item_type_name_unique_index_null_namespaces.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20220408001450_add_work_item_type_name_unique_index_null_namespaces.rb')
-rw-r--r--db/migrate/20220408001450_add_work_item_type_name_unique_index_null_namespaces.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20220408001450_add_work_item_type_name_unique_index_null_namespaces.rb b/db/migrate/20220408001450_add_work_item_type_name_unique_index_null_namespaces.rb
new file mode 100644
index 00000000000..bcb0e32a4e7
--- /dev/null
+++ b/db/migrate/20220408001450_add_work_item_type_name_unique_index_null_namespaces.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddWorkItemTypeNameUniqueIndexNullNamespaces < Gitlab::Database::Migration[1.0]
+ INDEX_NAME = :idx_work_item_types_on_namespace_id_and_name_null_namespace
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :work_item_types,
+ 'TRIM(BOTH FROM LOWER(name)), (namespace_id IS NULL)',
+ unique: true,
+ name: INDEX_NAME,
+ where: 'namespace_id IS NULL'
+ end
+
+ def down
+ remove_concurrent_index_by_name :work_item_types, INDEX_NAME
+ end
+end