debian-mirror-gitlab/db/migrate/20200715135130_create_vulnerability_historical_statistics.rb
2020-10-24 23:57:45 +05:30

34 lines
1.1 KiB
Ruby

# 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