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

20231024025629_cleanup_ci_pipeline_chat_data_pipeline_id_bigint.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e79f4eb43b7acd72bb49e5d1a14673a6f6bcf557 (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
28
29
# frozen_string_literal: true

class CleanupCiPipelineChatDataPipelineIdBigint < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  TABLE = :ci_pipeline_chat_data
  COLUMNS = [:pipeline_id]

  def up
    with_lock_retries(raise_on_exhaustion: true) do
      cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS) # rubocop:disable Migration/WithLockRetriesDisallowedMethod
    end
  end

  def down
    restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)

    add_concurrent_index(
      TABLE, :pipeline_id_convert_to_bigint,
      name: :index_ci_pipeline_chat_data_on_pipeline_id_convert_to_bigint,
      unique: true
    )
    add_concurrent_foreign_key(
      TABLE, :ci_pipelines,
      column: :pipeline_id_convert_to_bigint,
      on_delete: :cascade, validate: true, reverse_lock_order: true
    )
  end
end