Fixed upgrade procedure for fail_time_snmp and fail_time_snmp
authorzev <zev@netxms.org>
Wed, 4 Oct 2017 11:25:58 +0000 (14:25 +0300)
committerzev <zev@netxms.org>
Wed, 4 Oct 2017 11:26:13 +0000 (14:26 +0300)
include/netxmsdb.h
src/server/tools/nxdbmgr/upgrade.cpp

index f70a042..a7c0e18 100644 (file)
@@ -23,6 +23,6 @@
 #ifndef _netxmsdb_h
 #define _netxmsdb_h
 
-#define DB_FORMAT_VERSION   504
+#define DB_FORMAT_VERSION   505
 
 #endif
index 558d320..6046389 100644 (file)
@@ -645,7 +645,25 @@ BOOL moveFlagsFromOldTables(const TCHAR *tableName)
 }
 
 /**
- * Upgrade from V503 to V504
+ * Upgrade from V504 to V505 included in stable as 460
+ */
+static BOOL H_UpgradeFromV504(int currVersion, int newVersion)
+{
+   static const TCHAR *batch =
+            _T("UPDATE nodes SET fail_time_snmp=0 WHERE fail_time_snmp IS NULL\n")
+            _T("UPDATE nodes SET fail_time_agent=0 WHERE fail_time_agent IS NULL\n")
+            _T("<END>");
+   CHK_EXEC(SQLBatch(batch));
+
+   DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("fail_time_snmp"));
+   DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("fail_time_agent"));
+
+   CHK_EXEC(SetSchemaVersion(505));
+   return TRUE;
+}
+
+/**
+ * Upgrade from V503 to V504 included in stable as 459
  */
 static BOOL H_UpgradeFromV503(int currVersion, int newVersion)
 {
@@ -654,6 +672,7 @@ static BOOL H_UpgradeFromV503(int currVersion, int newVersion)
             _T("ALTER TABLE nodes ADD fail_time_agent integer\n")
             _T("<END>");
    CHK_EXEC(SQLBatch(batch));
+
    CHK_EXEC(SetSchemaVersion(504));
    return TRUE;
 }
@@ -12275,6 +12294,7 @@ static struct
    { 501, 502, H_UpgradeFromV501 },
    { 502, 503, H_UpgradeFromV502 },
    { 503, 504, H_UpgradeFromV503 },
+   { 504, 505, H_UpgradeFromV504 },
    { 0, 0, NULL }
 };