diff options
Diffstat (limited to 'db/post_migrate/20211006174114_add_namespace_index_on_type_sync.rb')
-rw-r--r-- | db/post_migrate/20211006174114_add_namespace_index_on_type_sync.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/db/post_migrate/20211006174114_add_namespace_index_on_type_sync.rb b/db/post_migrate/20211006174114_add_namespace_index_on_type_sync.rb new file mode 100644 index 00000000000..0185e4cbc5e --- /dev/null +++ b/db/post_migrate/20211006174114_add_namespace_index_on_type_sync.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddNamespaceIndexOnTypeSync < Gitlab::Database::Migration[1.0] + FULL_INDEX_NAME = 'index_namespaces_on_type_and_id' + PARTIAL_INDEX_NAME = 'index_namespaces_on_type_and_id_partial' + + disable_ddl_transaction! + + def up + add_concurrent_index :namespaces, [:type, :id], name: FULL_INDEX_NAME + + remove_concurrent_index_by_name :namespaces, name: PARTIAL_INDEX_NAME + end + + def down + add_concurrent_index(:namespaces, [:type, :id], where: 'type IS NOT NULL', name: PARTIAL_INDEX_NAME) + + remove_concurrent_index_by_name :namespaces, name: FULL_INDEX_NAME + end +end |