Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20230828153646_extend_push_rules_regex_limits.rb')
-rw-r--r--db/migrate/20230828153646_extend_push_rules_regex_limits.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/db/migrate/20230828153646_extend_push_rules_regex_limits.rb b/db/migrate/20230828153646_extend_push_rules_regex_limits.rb
new file mode 100644
index 00000000000..ba5e8e54f9f
--- /dev/null
+++ b/db/migrate/20230828153646_extend_push_rules_regex_limits.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+class ExtendPushRulesRegexLimits < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ REGEX_COLUMNS = %i[
+ force_push_regex
+ delete_branch_regex
+ commit_message_regex
+ author_email_regex
+ file_name_regex
+ branch_name_regex
+ ].freeze
+
+ LONG_REGEX_COLUMNS = %i[commit_message_negative_regex]
+
+ def up
+ REGEX_COLUMNS.each do |column_name|
+ add_check_constraint :push_rules, "char_length(#{column_name}) <= 511", "#{column_name}_size_constraint",
+ validate: false
+ end
+
+ LONG_REGEX_COLUMNS.each do |column_name|
+ add_check_constraint :push_rules, "char_length(#{column_name}) <= 2047", "#{column_name}_size_constraint",
+ validate: false
+ end
+ end
+
+ def down
+ REGEX_COLUMNS.each do |column_name|
+ remove_check_constraint :push_rules, "#{column_name}_size_constraint"
+ end
+
+ LONG_REGEX_COLUMNS.each do |column_name|
+ remove_check_constraint :push_rules, "#{column_name}_size_constraint"
+ end
+ end
+end