Commit 5914a534 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '355303-update-credit-card-limit' into 'master'

Update holder name limit to save 50 characters

See merge request gitlab-org/gitlab!82587
parents f2ad2fd4 5901bc87
...@@ -8,7 +8,7 @@ module Users ...@@ -8,7 +8,7 @@ module Users
belongs_to :user belongs_to :user
validates :holder_name, length: { maximum: 26 } validates :holder_name, length: { maximum: 50 }
validates :network, length: { maximum: 32 } validates :network, length: { maximum: 32 }
validates :last_digits, allow_nil: true, numericality: { validates :last_digits, allow_nil: true, numericality: {
greater_than_or_equal_to: 0, less_than_or_equal_to: 9999 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 ( ...@@ -21129,7 +21129,7 @@ CREATE TABLE user_credit_card_validations (
network text, network text,
CONSTRAINT check_1765e2b30f CHECK ((char_length(network) <= 32)), CONSTRAINT check_1765e2b30f CHECK ((char_length(network) <= 32)),
CONSTRAINT check_3eea080c91 CHECK (((last_digits >= 0) AND (last_digits <= 9999))), 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 ( CREATE TABLE user_custom_attributes (
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Users::CreditCardValidation do RSpec.describe Users::CreditCardValidation do
it { is_expected.to belong_to(:user) } 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_length_of(:network).is_at_most(32) }
it { is_expected.to validate_numericality_of(:last_digits).is_less_than_or_equal_to(9999) } 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