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

20200715135130_create_vulnerability_historical_statistics.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6afa123c341e5be5ad47ebc56302539ddc6cd770 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

class CreateVulnerabilityHistoricalStatistics < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  INDEX_NAME = 'index_vuln_historical_statistics_on_project_id_and_date'

  DOWNTIME = false

  def up
    with_lock_retries do
      create_table :vulnerability_historical_statistics do |t|
        t.timestamps_with_timezone null: false
        t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }
        t.integer :total, default: 0, null: false
        t.integer :critical, default: 0, null: false
        t.integer :high, default: 0, null: false
        t.integer :medium, default: 0, null: false
        t.integer :low, default: 0, null: false
        t.integer :unknown, default: 0, null: false
        t.integer :info, default: 0, null: false
        t.date :date, null: false
        t.integer :letter_grade, limit: 1, null: false
        t.index [:project_id, :date], unique: true, name: INDEX_NAME
      end
    end
  end

  def down
    with_lock_retries do
      drop_table :vulnerability_historical_statistics
    end
  end
end