diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-16 13:42:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-16 13:42:19 +0300 |
commit | 84d1bd786125c1c14a3ba5f63e38a4cc736a9027 (patch) | |
tree | f550fa965f507077e20dbb6d61a8269a99ef7107 /db/post_migrate/20231213014658_remove_plain_text_credit_card_columns.rb | |
parent | 3a105e36e689f7b75482236712f1a47fd5a76814 (diff) |
Add latest changes from gitlab-org/gitlab@16-8-stable-eev16.8.0-rc42
Diffstat (limited to 'db/post_migrate/20231213014658_remove_plain_text_credit_card_columns.rb')
-rw-r--r-- | db/post_migrate/20231213014658_remove_plain_text_credit_card_columns.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/db/post_migrate/20231213014658_remove_plain_text_credit_card_columns.rb b/db/post_migrate/20231213014658_remove_plain_text_credit_card_columns.rb new file mode 100644 index 00000000000..c1ecf63012d --- /dev/null +++ b/db/post_migrate/20231213014658_remove_plain_text_credit_card_columns.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +class RemovePlainTextCreditCardColumns < Gitlab::Database::Migration[2.2] + milestone '16.8' + + disable_ddl_transaction! + + FULL_MATCH_INDEX_NAME = 'index_user_credit_card_validations_meta_data_full_match_lower' + FULL_MATCH_FIELDS = 'lower(holder_name), expiration_date, last_digits, credit_card_validated_at' + + PARTIAL_MATCH_INDEX_NAME = 'index_user_credit_card_validations_meta_data_partial_match' + PARTIAL_MATCH_FIELDS = 'expiration_date, last_digits, network, credit_card_validated_at' + + def up + with_lock_retries do + remove_column :user_credit_card_validations, :holder_name, if_exists: true + remove_column :user_credit_card_validations, :network, if_exists: true + remove_column :user_credit_card_validations, :expiration_date, if_exists: true + remove_column :user_credit_card_validations, :last_digits, if_exists: true + end + end + + def down + add_column :user_credit_card_validations, :holder_name, :text, if_not_exists: true + add_column :user_credit_card_validations, :network, :text, if_not_exists: true + add_column :user_credit_card_validations, :expiration_date, :date, if_not_exists: true + add_column :user_credit_card_validations, :last_digits, :integer, limit: 2, if_not_exists: true + + add_text_limit :user_credit_card_validations, :holder_name, 50 + add_text_limit :user_credit_card_validations, :network, 32 + add_check_constraint :user_credit_card_validations, 'last_digits BETWEEN 0 AND 9999', + 'credit_card_last_digits_range' + + add_concurrent_index :user_credit_card_validations, FULL_MATCH_FIELDS, name: FULL_MATCH_INDEX_NAME + add_concurrent_index :user_credit_card_validations, PARTIAL_MATCH_FIELDS, name: PARTIAL_MATCH_INDEX_NAME + end +end |