summaryrefslogtreecommitdiff
path: root/db/migrate/20211210025754_alter_constraint_of_phone.rb
blob: 1644fbe9000e50cf120d20841e970adfba9ef33c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

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

  def up
    constraint_phone = check_constraint_name('verification_codes', 'phone', 'max_length')
    remove_check_constraint(:verification_codes, constraint_phone)
    add_check_constraint(:verification_codes, 'char_length(phone) <= 50', constraint_phone)
  end

  def down
    constraint_phone = check_constraint_name('verification_codes', 'phone', 'max_length')
    remove_check_constraint(:verification_codes, constraint_phone)
    add_check_constraint(:verification_codes, 'char_length(phone) <= 32', constraint_phone)
  end
end