diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-06 18:06:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-06 18:06:23 +0300 |
commit | 5277f8e69e935eabd3bf8c5e7833471b5bfad1d9 (patch) | |
tree | 405b231961d09fa399e7c4311235ee67a5da6727 /db | |
parent | 4dcee85bb2384604153165f1296fb86d609c71cc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb | 9 | ||||
-rw-r--r-- | db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb | 26 | ||||
-rw-r--r-- | db/schema.rb | 3 |
3 files changed, 37 insertions, 1 deletions
diff --git a/db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb b/db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb new file mode 100644 index 00000000000..8fb657bf9e7 --- /dev/null +++ b/db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddReportTypeToVulnerabilities < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def change + add_column :vulnerabilities, :report_type, :integer, limit: 2 + end +end diff --git a/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb b/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb new file mode 100644 index 00000000000..6b7a158584d --- /dev/null +++ b/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class SetReportTypeForVulnerabilities < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def up + # set report_type based on associated vulnerability_occurrences + execute <<~SQL + UPDATE vulnerabilities + SET report_type = vulnerability_occurrences.report_type + FROM vulnerability_occurrences + WHERE vulnerabilities.id = vulnerability_occurrences.vulnerability_id + SQL + + # set default report_type for orphan vulnerabilities (there should be none but...) + execute 'UPDATE vulnerabilities SET report_type = 0 WHERE report_type IS NULL' + + change_column_null :vulnerabilities, :report_type, false + end + + def down + change_column_null :vulnerabilities, :report_type, true + + execute 'UPDATE vulnerabilities SET report_type = NULL' + end +end diff --git a/db/schema.rb b/db/schema.rb index 066ae22cbd7..220e57527a5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_10_29_191901) do +ActiveRecord::Schema.define(version: 2019_11_05_094625) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" @@ -3915,6 +3915,7 @@ ActiveRecord::Schema.define(version: 2019_10_29_191901) do t.boolean "severity_overridden", default: false t.integer "confidence", limit: 2, null: false t.boolean "confidence_overridden", default: false + t.integer "report_type", limit: 2, null: false t.index ["author_id"], name: "index_vulnerabilities_on_author_id" t.index ["closed_by_id"], name: "index_vulnerabilities_on_closed_by_id" t.index ["due_date_sourcing_milestone_id"], name: "index_vulnerabilities_on_due_date_sourcing_milestone_id" |