debian-mirror-gitlab/db/migrate/20220107091629_add_route_namespace_index.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
564 B
Ruby
Raw Normal View History

2022-03-02 08:16:31 +05:30
# frozen_string_literal: true
class AddRouteNamespaceIndex < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = 'index_routes_on_namespace_id'
def up
add_concurrent_index :routes, :namespace_id, unique: true, name: INDEX_NAME
add_concurrent_foreign_key :routes, :namespaces, column: :namespace_id, on_delete: :nullify, reverse_lock_order: true
end
def down
with_lock_retries do
remove_foreign_key_if_exists :routes, column: :namespace_id
end
remove_concurrent_index_by_name :routes, INDEX_NAME
end
end