debian-mirror-gitlab/db/migrate/20200813143304_add_new_external_diff_migration_index.rb
2020-10-24 23:57:45 +05:30

24 lines
546 B
Ruby

# frozen_string_literal: true
class AddNewExternalDiffMigrationIndex < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_merge_request_diffs_by_id_partial'
disable_ddl_transaction!
def up
add_concurrent_index(
:merge_request_diffs,
:id,
name: INDEX_NAME,
where: 'files_count > 0 AND ((NOT stored_externally) OR (stored_externally IS NULL))'
)
end
def down
remove_concurrent_index_by_name(:merge_request_diffs, INDEX_NAME)
end
end