summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220510003916_remove_tmp_empty_traversal_ids_root_namespace_index.rb
blob: 424c6f164e724349338f43157f44544de3dfa5b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

class RemoveTmpEmptyTraversalIdsRootNamespaceIndex < Gitlab::Database::Migration[2.0]
  disable_ddl_transaction!

  ROOT_NS_INDEX_NAME = 'tmp_index_namespaces_empty_traversal_ids_with_root_namespaces'

  def up
    remove_concurrent_index :namespaces, :id, name: ROOT_NS_INDEX_NAME
  end

  def down
    where_sql = "parent_id IS NULL AND traversal_ids = '{}'"
    add_concurrent_index :namespaces, :id, where: where_sql, name: ROOT_NS_INDEX_NAME
  end
end