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

class ResetSeverityLevelsToNewDefault < ActiveRecord::Migration[6.1]
  ALL_SEVERITY_LEVELS = 6 # ::Enums::Vulnerability::SEVERITY_LEVELS.count

  def up
    execute(<<~SQL.squish)
      UPDATE approval_project_rules
      SET severity_levels = '{unknown, high, critical}'
      WHERE array_length(severity_levels, 1) = #{ALL_SEVERITY_LEVELS};
    SQL
  end

  def down
    # no-op
  end
end