[Openvas-commits] r6149 - in trunk/openvas-manager: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Dec 16 14:39:09 CET 2009


Author: mattm
Date: 2009-12-16 14:39:08 +0100 (Wed, 16 Dec 2009)
New Revision: 6149

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/tasks_sql.h
Log:
	Add database migration from version 7 to 8.

	* src/tasks_sql.h (migrate_7_to_8): New function.
	(database_migrators): Add migrate_7_to_8.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-12-16 12:49:06 UTC (rev 6148)
+++ trunk/openvas-manager/ChangeLog	2009-12-16 13:39:08 UTC (rev 6149)
@@ -1,5 +1,12 @@
 2009-12-16  Matthew Mundell <matthew.mundell at intevation.de>
 
+	Add database migration from version 7 to 8.
+
+	* src/tasks_sql.h (migrate_7_to_8): New function.
+	(database_migrators): Add migrate_7_to_8.
+
+2009-12-16  Matthew Mundell <matthew.mundell at intevation.de>
+
 	Separate credential name and login name for LSC credentials.
 
 	* src/tasks_sql.h (DATABASE_VERSION): Increase to 8, for changes to table

Modified: trunk/openvas-manager/src/tasks_sql.h
===================================================================
--- trunk/openvas-manager/src/tasks_sql.h	2009-12-16 12:49:06 UTC (rev 6148)
+++ trunk/openvas-manager/src/tasks_sql.h	2009-12-16 13:39:08 UTC (rev 6149)
@@ -1686,6 +1686,40 @@
 }
 
 /**
+ * @brief Migrate the database from version 7 to version 8.
+ *
+ * @return 0 success, -1 error.
+ */
+static int
+migrate_7_to_8 ()
+{
+  sql ("BEGIN EXCLUSIVE;");
+
+  /* Ensure that the database is currently version 7. */
+
+  if (manage_db_version () != 7)
+    {
+      sql ("END;");
+      return -1;
+    }
+
+  /* Update the database. */
+
+  /* The lsc_credentials table got a login column. */
+
+  sql ("ALTER TABLE lsc_credentials ADD COLUMN login;");
+  sql ("UPDATE lsc_credentials SET login = name;");
+
+  /* Set the database version to 8. */
+
+  set_db_version (8);
+
+  sql ("COMMIT;");
+
+  return 0;
+}
+
+/**
  * @brief Array of database version migrators.
  */
 static migrator_t database_migrators[]
@@ -1697,6 +1731,7 @@
     {5, migrate_4_to_5},
     {6, migrate_5_to_6},
     {7, migrate_6_to_7},
+    {8, migrate_7_to_8},
     /* End marker. */
     {-1, NULL}};
 



More information about the Openvas-commits mailing list