Skip to content

Commit

Permalink
Merge pull request #1498 from timopollmeier/migration-fix
Browse files Browse the repository at this point in the history
Fix migration to DB version 242 from gvmd 20.08
  • Loading branch information
nichtsfrei authored Apr 19, 2021
2 parents ca203c4 + 1cd170f commit da532c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
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

0 comments on commit da532c7

Please sign in to comment.