diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /lib/gitlab/background_migration/truncate_overlong_vulnerability_html_titles.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) | |
download | gitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'lib/gitlab/background_migration/truncate_overlong_vulnerability_html_titles.rb')
-rw-r--r-- | lib/gitlab/background_migration/truncate_overlong_vulnerability_html_titles.rb | 22 |
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 |