Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix migration to DB version 242 from gvmd 20.08 #1498

Merged
merged 2 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Fixed
- Improve VT version handling for CVE & OVAL results [#1496](https://github.com/greenbone/gvmd/pull/1496)
- Fix migration to DB version 242 from gvmd 20.08 [#1498](https://github.com/greenbone/gvmd/pull/1498)

[21.4.0]: https://github.com/greenbone/gvmd/compare/v21.4.0...gvmd-21.04

Expand Down
18 changes: 14 additions & 4 deletions src/manage_migrators.c
Original file line number Diff line number Diff line change
Expand Up @@ -2627,10 +2627,20 @@ migrate_241_to_242 ()

sql ("ALTER TABLE results_trash DROP COLUMN IF EXISTS score;");

/* Change the vt_severities table to a CVSS score */
sql ("ALTER TABLE vt_severities ALTER COLUMN score"
" SET DATA TYPE double precision;");
sql ("UPDATE vt_severities SET score = round((score / 10.0)::numeric, 1);");
/* Change the vt_severities table to use a CVSS score
* if it already exists (migrating from a 21.04 development version) */
if (sql_int ("SELECT EXISTS (SELECT * FROM information_schema.tables"
" WHERE table_catalog = '%s'"
" AND table_schema = 'public'"
" AND table_name = 'vt_severities')"
" ::integer;",
sql_database ()))
{
sql ("ALTER TABLE vt_severities ALTER COLUMN score"
" SET DATA TYPE double precision;");
sql ("UPDATE vt_severities"
" SET score = round((score / 10.0)::numeric, 1);");
}

/* Set the database version to 242. */

Expand Down