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 (backport #1498) #1500

Merged
merged 4 commits into from
Apr 20, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Use pg-gvm extension for C PostgreSQL functions [#1400](https://github.com/greenbone/gvmd/pull/1400), [#1453](https://github.com/greenbone/gvmd/pull/1453)

### 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)

### Removed

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