Author: mattm
Date: 2016-10-13 14:56:32 +0200 (Thu, 13 Oct 2016)
New Revision: 26399

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage_migrators.c
Log:
        * src/manage_migrators.c (migrate_153_to_154): Reset sequences.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog     2016-10-13 12:54:49 UTC (rev 26398)
+++ trunk/openvas-manager/ChangeLog     2016-10-13 12:56:32 UTC (rev 26399)
@@ -1,5 +1,9 @@
 2016-10-13  Matthew Mundell <matthew.mund...@greenbone.net>
 
+       * src/manage_migrators.c (migrate_153_to_154): Reset sequences.
+
+2016-10-13  Matthew Mundell <matthew.mund...@greenbone.net>
+
        * tools/openvas-migrate-to-postgres.in (cleanup_sqlite_db): Remove stray
        role_users_trash.
        (copy_data): Adjust logs.

Modified: trunk/openvas-manager/src/manage_migrators.c
===================================================================
--- trunk/openvas-manager/src/manage_migrators.c        2016-10-13 12:54:49 UTC 
(rev 26398)
+++ trunk/openvas-manager/src/manage_migrators.c        2016-10-13 12:56:32 UTC 
(rev 26399)
@@ -10446,6 +10446,20 @@
        " SELECT id, 'secret', password FROM lsc_credentials_trash"
        "  WHERE password IS NOT NULL AND private_key = ';;encrypted;;';");
 
+  /* Reset the sequences because we messed with the SERIAL column "id". */
+
+  sql ("SELECT setval ('credentials_id_seq',"
+       "               (SELECT max (id) + 1 FROM credentials));");
+
+  sql ("SELECT setval ('credentials_trash_id_seq',"
+       "               (SELECT max (id) + 1 FROM credentials_trash));");
+
+  sql ("SELECT setval ('credentials_data_id_seq',"
+       "               (SELECT max (id) + 1 FROM credentials_data));");
+
+  sql ("SELECT setval ('credentials_trash_data_id_seq',"
+       "               (SELECT max (id) + 1 FROM credentials_trash_data));");
+
   /* Set type for existing credentials */
   init_iterator (&credentials,
                  "SELECT id, password, private_key, 0"

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits

Reply via email to