Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
67cd3d9a
Commit
67cd3d9a
authored
Nov 20, 2019
by
Victor Zagorodny
Committed by
Andreas Brandl
Nov 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the flakiness of SetReportTypeForVulnerabilities migration
parent
4aa274aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb
...ate/20191105094625_set_report_type_for_vulnerabilities.rb
+11
-3
No files found.
db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb
View file @
67cd3d9a
...
...
@@ -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...)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment