summaryrefslogtreecommitdiff
path: root/db/migrate/20220310101118_update_holder_name_limit.rb
blob: 55eb8f75d701fd7ee5a174a44a4d6d529a608993 (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
# frozen_string_literal: true

# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class UpdateHolderNameLimit < Gitlab::Database::Migration[1.0]
  disable_ddl_transaction!

  def up
    add_text_limit :user_credit_card_validations, :holder_name, 50, constraint_name: new_constraint_name
    remove_text_limit :user_credit_card_validations, :holder_name, constraint_name: old_constraint_name
  end

  def down
    add_text_limit :user_credit_card_validations, :holder_name, 26, validate: false, constraint_name: old_constraint_name
    remove_text_limit :user_credit_card_validations, :holder_name, constraint_name: new_constraint_name
  end

  private

  def old_constraint_name
    check_constraint_name(:user_credit_card_validations, :holder_name, 'max_length')
  end

  def new_constraint_name
    check_constraint_name(:user_credit_card_validations, :holder_name, 'max_length_50')
  end
end