Commit 5901bc87 authored by Shreyas Agarwal's avatar Shreyas Agarwal Committed by Adam Hegyi

Update holder name column to 50 limit constraint

A constraint of 26 characters were added to the holder_name text column.
Unfortunately, the Zuora accepts 50 characters as the limit and when sending data
to GL.com errors were raised. The MR would change the limit to 50 within GL.com database.

Changelog: fixed
parent a29830c9
......@@ -8,7 +8,7 @@ module Users
belongs_to :user
validates :holder_name, length: { maximum: 26 }
validates :holder_name, length: { maximum: 50 }
validates :network, length: { maximum: 32 }
validates :last_digits, allow_nil: true, numericality: {
greater_than_or_equal_to: 0, less_than_or_equal_to: 9999
......
# 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
e4d6111f19f05b42b51e8d066e221205460514cef88ecf15ca99aa59788c4153
\ No newline at end of file
......@@ -21129,7 +21129,7 @@ CREATE TABLE user_credit_card_validations (
network text,
CONSTRAINT check_1765e2b30f CHECK ((char_length(network) <= 32)),
CONSTRAINT check_3eea080c91 CHECK (((last_digits >= 0) AND (last_digits <= 9999))),
CONSTRAINT check_eafe45d88b CHECK ((char_length(holder_name) <= 26))
CONSTRAINT check_cc0c8dc0fe CHECK ((char_length(holder_name) <= 50))
);
CREATE TABLE user_custom_attributes (
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Users::CreditCardValidation do
it { is_expected.to belong_to(:user) }
it { is_expected.to validate_length_of(:holder_name).is_at_most(26) }
it { is_expected.to validate_length_of(:holder_name).is_at_most(50) }
it { is_expected.to validate_length_of(:network).is_at_most(32) }
it { is_expected.to validate_numericality_of(:last_digits).is_less_than_or_equal_to(9999) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment