Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20210817024335_prepare_indexes_for_events_bigint_conversion.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1d102d6216c48bccc70009c25fc30ae415ec31de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

class PrepareIndexesForEventsBigintConversion < ActiveRecord::Migration[6.1]
  include Gitlab::Database::MigrationHelpers

  TABLE_NAME = 'events'

  def up
    prepare_async_index TABLE_NAME, :id_convert_to_bigint, unique: true,
      name: :index_events_on_id_convert_to_bigint

    prepare_async_index TABLE_NAME, [:project_id, :id_convert_to_bigint],
      name: :index_events_on_project_id_and_id_convert_to_bigint

    prepare_async_index TABLE_NAME, [:project_id, :id_convert_to_bigint], order: { id_convert_to_bigint: :desc },
      where: 'action = 7', name: :index_events_on_project_id_and_id_bigint_desc_on_merged_action
  end

  def down
    unprepare_async_index_by_name TABLE_NAME, :index_events_on_id_convert_to_bigint
    unprepare_async_index_by_name TABLE_NAME, :index_events_on_project_id_and_id_convert_to_bigint
    unprepare_async_index_by_name TABLE_NAME, :index_events_on_project_id_and_id_bigint_desc_on_merged_action
  end
end