summaryrefslogtreecommitdiff
path: root/db/migrate/20210420120734_initialize_conversion_of_ci_job_artifacts_to_bigint.rb
blob: cc8f06868418bf15327a30203ec311916a7e471d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

class InitializeConversionOfCiJobArtifactsToBigint < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  TABLE = :ci_job_artifacts
  COLUMNS = %i(id job_id)
  TARGET_COLUMNS = COLUMNS.map { |col| "#{col}_convert_to_bigint" }

  def up
    initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
  end

  def down
    trigger_name = rename_trigger_name(TABLE, COLUMNS, TARGET_COLUMNS)
    remove_rename_triggers TABLE, trigger_name

    TARGET_COLUMNS.each do |column|
      remove_column TABLE, column
    end
  end
end