2 ** nxdbmgr - NetXMS database manager
3 ** Copyright (C) 2004-2017 Victor Kirhenshtein
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ** File: upgrade_v22.cpp
26 * Upgrade from 22.1 to 30.0
28 static bool H_UpgradeFromV1()
30 CHK_EXEC(SetMajorSchemaVersion(30, 0));
35 * Upgrade from 22.0 to 22.1
37 static bool H_UpgradeFromV0()
39 int count
= ConfigReadInt(_T("NumberOfDataCollectors"), 250);
41 _sntprintf(value
, 64,_T("%d"), std::max(250, count
));
42 CHK_EXEC(CreateConfigParam(_T("DataCollector.ThreadPool.BaseSize"), _T("10"), _T("Base size for data collector thread pool."), 'I', true, true, false, false));
43 CHK_EXEC(CreateConfigParam(_T("DataCollector.ThreadPool.MaxSize"), value
, _T("Maximum size for data collector thread pool."), 'I', true, true, false, false));
44 CHK_EXEC(SQLQuery(_T("UPDATE config SET default_value='250' WHERE var_name='DataCollector.ThreadPool.MaxSize'")));
45 CHK_EXEC(SQLQuery(_T("DELETE FROM config WHERE var_name='NumberOfDataCollectors'")));
46 CHK_EXEC(SetMinorSchemaVersion(1));
58 bool (* upgradeProc
)();
61 { 1, 30, 0, H_UpgradeFromV1
},
62 { 0, 22, 1, H_UpgradeFromV0
},
67 * Upgrade database to new version
69 bool MajorSchemaUpgrade_V22()
72 if (!DBGetSchemaVersion(g_hCoreDB
, &major
, &minor
))
77 // Find upgrade procedure
79 for(i
= 0; s_dbUpgradeMap
[i
].upgradeProc
!= NULL
; i
++)
80 if (s_dbUpgradeMap
[i
].version
== minor
)
82 if (s_dbUpgradeMap
[i
].upgradeProc
== NULL
)
84 _tprintf(_T("Unable to find upgrade procedure for version 22.%d\n"), minor
);
87 _tprintf(_T("Upgrading from version 22.%d to %d.%d\n"), minor
, s_dbUpgradeMap
[i
].nextMajor
, s_dbUpgradeMap
[i
].nextMinor
);
89 if (s_dbUpgradeMap
[i
].upgradeProc())
92 if (!DBGetSchemaVersion(g_hCoreDB
, &major
, &minor
))
97 _tprintf(_T("Rolling back last stage due to upgrade errors...\n"));
98 DBRollback(g_hCoreDB
);