summaryrefslogtreecommitdiff
path: root/db/post_migrate/20230317195228_prepare_async_sent_notifications_index.rb
blob: ea035b3ee585a51b3415ea9e03a422459b6b94be (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
25
26
27
# frozen_string_literal: true

class PrepareAsyncSentNotificationsIndex < Gitlab::Database::Migration[2.1]
  include Gitlab::Database::MigrationHelpers::ConvertToBigint

  TABLE_NAME = :sent_notifications
  COLUMN_NAME = :id_convert_to_bigint
  INDEX_NAME = :index_sent_notifications_on_id_convert_to_bigint

  def up
    return unless should_run?

    prepare_async_index TABLE_NAME, COLUMN_NAME, name: INDEX_NAME, unique: true
  end

  def down
    return unless should_run?

    unprepare_async_index TABLE_NAME, COLUMN_NAME, name: INDEX_NAME
  end

  private

  def should_run?
    com_or_dev_or_test_but_not_jh?
  end
end