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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-20 21:06:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-20 21:06:04 +0300
commitfdffdcf1abaa2cab903f1d32610eb562cdf53906 (patch)
treede74d5ee1319ebb62faacfd841a98acf3737901d /db
parent97b63407ef0ecacc239fe320a9b87eefdebfe70c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb b/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb
index 6b7a158584d..5a8529c24d7 100644
--- a/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb
+++ b/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb
@@ -4,12 +4,20 @@ class SetReportTypeForVulnerabilities < ActiveRecord::Migration[5.2]
DOWNTIME = false
def up
- # set report_type based on associated vulnerability_occurrences
+ # set report_type based on vulnerability_occurrences from which the vulnerabilities were promoted,
+ # that is, first vulnerability_occurrences among those having the same vulnerability_id
execute <<~SQL
+ WITH first_findings_for_vulnerabilities AS (
+ SELECT MIN(id) AS id, vulnerability_id
+ FROM vulnerability_occurrences
+ WHERE vulnerability_id IS NOT NULL
+ GROUP BY vulnerability_id
+ )
UPDATE vulnerabilities
SET report_type = vulnerability_occurrences.report_type
- FROM vulnerability_occurrences
- WHERE vulnerabilities.id = vulnerability_occurrences.vulnerability_id
+ FROM vulnerability_occurrences, first_findings_for_vulnerabilities
+ WHERE vulnerability_occurrences.id = first_findings_for_vulnerabilities.id
+ AND vulnerabilities.id = vulnerability_occurrences.vulnerability_id
SQL
# set default report_type for orphan vulnerabilities (there should be none but...)