Skip to content

Commit

Permalink
Add migrator to add column solution to table nvts.
Browse files Browse the repository at this point in the history
  • Loading branch information
janowagner committed Aug 11, 2019
1 parent 4ac7224 commit 08cd580
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ include (CPack)

## Variables

set (GVMD_DATABASE_VERSION 215)
set (GVMD_DATABASE_VERSION 216)

set (GVMD_SCAP_DATABASE_VERSION 15)

Expand Down
37 changes: 19 additions & 18 deletions src/manage_migrators.c
Original file line number Diff line number Diff line change
Expand Up @@ -1163,71 +1163,71 @@ migrate_213_to_214 ()
}

/**
* @brief Migrate the database from version 215 to version 216.
* @brief Migrate the database from version 214 to version 215.
*
* @return 0 success, -1 error.
*/
int
migrate_215_to_216 ()
migrate_214_to_215 ()
{
sql_begin_immediate ();

/* Ensure that the database is currently version 215. */
/* Ensure that the database is currently version 214. */

if (manage_db_version () != 215)
if (manage_db_version () != 214)
{
sql_rollback ();
return -1;
}

/* Update the database. */

/* Extend table "nvts" with additional column "solution" */
sql ("ALTER TABLE IF EXISTS nvts ADD COLUMN solution text;");
/* The column nbefile was removed from reports. */
sql ("ALTER TABLE reports DROP COLUMN nbefile;");

/* Set the database version to 216. */
/* Set the database version to 215 */

set_db_version (216);
set_db_version (215);

sql_commit ();

return 0;
}

#undef UPDATE_DASHBOARD_SETTINGS

/**
* @brief Migrate the database from version 214 to version 215.
* @brief Migrate the database from version 215 to version 216.
*
* @return 0 success, -1 error.
*/
int
migrate_214_to_215 ()
migrate_215_to_216 ()
{
sql_begin_immediate ();

/* Ensure that the database is currently version 214. */
/* Ensure that the database is currently version 215. */

if (manage_db_version () != 214)
if (manage_db_version () != 215)
{
sql_rollback ();
return -1;
}

/* Update the database. */

/* The column nbefile was removed from reports. */
sql ("ALTER TABLE reports DROP COLUMN nbefile;");
/* Extend table "nvts" with additional column "solution" */
sql ("ALTER TABLE IF EXISTS nvts ADD COLUMN solution text;");

/* Set the database version to 215 */
/* Set the database version to 216. */

set_db_version (215);
set_db_version (216);

sql_commit ();

return 0;
}

#undef UPDATE_DASHBOARD_SETTINGS

/**
* @brief The oldest version for which migration is supported
*/
Expand All @@ -1247,6 +1247,7 @@ static migrator_t database_migrators[] = {
{213, migrate_212_to_213},
{214, migrate_213_to_214},
{215, migrate_214_to_215},
{216, migrate_215_to_216},
/* End marker. */
{-1, NULL}};

Expand Down

0 comments on commit 08cd580

Please sign in to comment.