summaryrefslogtreecommitdiff
path: root/db/migrate/20200715135130_create_vulnerability_historical_statistics.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20200715135130_create_vulnerability_historical_statistics.rb')
-rw-r--r--db/migrate/20200715135130_create_vulnerability_historical_statistics.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/db/migrate/20200715135130_create_vulnerability_historical_statistics.rb b/db/migrate/20200715135130_create_vulnerability_historical_statistics.rb
new file mode 100644
index 00000000000..6afa123c341
--- /dev/null
+++ b/db/migrate/20200715135130_create_vulnerability_historical_statistics.rb
@@ -0,0 +1,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