debian-mirror-gitlab/db/migrate/20220112232605_add_member_namespace_index.rb
2022-03-02 08:16:31 +05:30

19 lines
599 B
Ruby

# frozen_string_literal: true
class AddMemberNamespaceIndex < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = 'index_members_on_member_namespace_id'
def up
add_concurrent_index :members, :member_namespace_id, unique: false, name: INDEX_NAME
add_concurrent_foreign_key :members, :namespaces, column: :member_namespace_id, on_delete: :nullify, reverse_lock_order: true
end
def down
with_lock_retries do
remove_foreign_key_if_exists :members, column: :member_namespace_id
end
remove_concurrent_index_by_name :members, INDEX_NAME
end
end