summaryrefslogtreecommitdiff
path: root/db/post_migrate/20221110100600_add_temp_index_on_overlong_vulnerability_html_title.rb
blob: 5ff56874e116a0ed330640b85036d4de67f1fdb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class AddTempIndexOnOverlongVulnerabilityHtmlTitle < Gitlab::Database::Migration[2.0]
  INDEX_NAME = 'tmp_index_vulnerability_overlong_title_html'

  disable_ddl_transaction!

  def up
    # Temporary index to speed up the truncation of vulnerabilities with invalid html title length
    add_concurrent_index :vulnerabilities, [:id],
      name: INDEX_NAME,
      where: "LENGTH(title_html) > 800"
  end

  def down
    remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME
  end
end