summaryrefslogtreecommitdiff
path: root/db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb
blob: 81e73effe7bf0cf62af29d5b2fba2e08b967c3f1 (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
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

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

  def up
    prepare_async_index :ci_job_artifacts, :id_convert_to_bigint, unique: true,
                                                                  name: :index_ci_job_artifact_on_id_convert_to_bigint

    prepare_async_index :ci_job_artifacts,
                        [:project_id, :id_convert_to_bigint],
                        where: 'file_type = 18', name: :index_ci_job_artifacts_for_terraform_reports_bigint

    prepare_async_index :ci_job_artifacts, :id_convert_to_bigint,
                        where: 'file_type = 18',
                        name: :index_ci_job_artifacts_id_for_terraform_reports_bigint

    prepare_async_index :ci_job_artifacts,
                        [:expire_at, :job_id_convert_to_bigint],
                        name: :index_ci_job_artifacts_on_expire_at_and_job_id_bigint

    prepare_async_index :ci_job_artifacts,
                        [:job_id_convert_to_bigint, :file_type],
                        unique: true, name: :index_ci_job_artifacts_on_job_id_and_file_type_bigint
  end

  def down
    unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_on_job_id_and_file_type_bigint

    unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_on_expire_at_and_job_id_bigint

    unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_id_for_terraform_reports_bigint

    unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_for_terraform_reports_bigint

    unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifact_on_id_convert_to_bigint
  end
end