Source
/* sysmaps_elements.elementid for trigger map elements (2) should be migrated to table sysmap_element_trigger */
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/*
* 3.4 development database patches
*/
static int DBpatch_3030000(void)
{
const zbx_db_field_t field = {"ipmi_authtype", "-1", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
return DBset_default("hosts", &field);
}
static int DBpatch_3030001(void)
{
const zbx_db_field_t field = {"snmp_oid", "", NULL, NULL, 512, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
return DBmodify_field_type("items", &field, NULL);
}
static int DBpatch_3030002(void)
{
const zbx_db_field_t field = {"key_", "", NULL, NULL, 512, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
return DBmodify_field_type("dchecks", &field, NULL);
}
static int DBpatch_3030003(void)
{
return DBdrop_field("proxy_dhistory", "type");
}
static int DBpatch_3030004(void)
{
return DBdrop_field("proxy_dhistory", "key_");
}
static int DBpatch_3030005(void)
{
return DBdrop_foreign_key("dservices", 2);
}
static int DBpatch_3030006(void)
{
return DBdrop_index("dservices", "dservices_1");
}
static int DBpatch_3030007(void)
{
zbx_db_row_t row;
zbx_db_result_t result;
zbx_vector_uint64_t dserviceids;
zbx_uint64_t dserviceid;
int ret = SUCCEED;
zbx_vector_uint64_create(&dserviceids);
/* After dropping fields type and key_ from table dservices there is no guarantee that a unique
index with fields dcheckid, ip and port can be created. To create a unique index for the same
fields later this will delete rows where all three of them are identical only leaving the latest. */
result = zbx_db_select(
"select ds.dserviceid"
" from dservices ds"
" where not exists ("
"select null"
" from dchecks dc"
" where ds.dcheckid = dc.dcheckid"
" and ds.type = dc.type"
" and ds.key_ = dc.key_"
")");