debian-mirror-gitlab/db/post_migrate/20200917165525_update_index_on_namespaces_for_type_and_id.rb
2021-01-03 14:25:43 +05:30

24 lines
677 B
Ruby

# frozen_string_literal: true
class UpdateIndexOnNamespacesForTypeAndId < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
OLD_INDEX_NAME = 'index_namespaces_on_type_partial'
NEW_INDEX_NAME = 'index_namespaces_on_type_and_id_partial'
def up
add_concurrent_index(:namespaces, [:type, :id], where: 'type IS NOT NULL', name: NEW_INDEX_NAME)
remove_concurrent_index_by_name(:namespaces, OLD_INDEX_NAME)
end
def down
add_concurrent_index(:namespaces, :type, where: 'type IS NOT NULL', name: OLD_INDEX_NAME)
remove_concurrent_index_by_name(:namespaces, NEW_INDEX_NAME)
end
end