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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-10 06:07:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-10 06:07:25 +0300
commit4a6dacc8662ed65c0b83a3715e4eb05a78168db1 (patch)
tree04aced9d7d60c1213db9d5152158afe02126599f /lib/gitlab/background_migration
parent070ac34d473978dc27ea2878ed1cf17865e24e9a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/background_migration')
-rw-r--r--lib/gitlab/background_migration/truncate_overlong_vulnerability_html_titles.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/truncate_overlong_vulnerability_html_titles.rb b/lib/gitlab/background_migration/truncate_overlong_vulnerability_html_titles.rb
new file mode 100644
index 00000000000..5ae1698b910
--- /dev/null
+++ b/lib/gitlab/background_migration/truncate_overlong_vulnerability_html_titles.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # Truncate the Vulnerability html_title if it exceeds 800 chars
+ class TruncateOverlongVulnerabilityHtmlTitles < BatchedMigrationJob
+ feature_category :vulnerability_management
+ scope_to ->(relation) { relation.where("LENGTH(title_html) > 800") }
+ operation_name :truncate_vulnerability_title_htmls
+
+ class Vulnerability < ApplicationRecord # rubocop:disable Style/Documentation
+ self.table_name = "vulnerabilities"
+ end
+
+ def perform
+ each_sub_batch do |sub_batch|
+ sub_batch.update_all("title_html = left(title_html, 800)")
+ end
+ end
+ end
+ end
+end