#include "dbupgrade.h"
#include "zbxdbhigh.h"
#include "zbx_host_constants.h"
#ifndef HAVE_SQLITE3
static int DBpatch_4030000(void)
{
const zbx_db_field_t field = {"host", "", NULL, NULL, 128, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
return DBmodify_field_type("autoreg_host", &field, NULL);
}
static int DBpatch_4030001(void)
{
const zbx_db_field_t field = {"host", "", NULL, NULL, 128, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
return DBmodify_field_type("proxy_autoreg_host", &field, NULL);
}
static int DBpatch_4030002(void)
{
const zbx_db_field_t field = {"host", "", NULL, NULL, 128, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
return DBmodify_field_type("host_discovery", &field, NULL);
}
static int DBpatch_4030003(void)
{
const zbx_db_table_t table =
{"item_rtdata", "itemid", 0,
{
{"itemid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
{"lastlogsize", "0", NULL, NULL, 0, ZBX_TYPE_UINT, ZBX_NOTNULL, 0},
{"state", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
{"mtime", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
{"error", "", NULL, NULL, 2048, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
{0}
},
NULL
};
return DBcreate_table(&table);
}
static int DBpatch_4030004(void)
{
const zbx_db_field_t field = {"itemid", NULL, "items", "itemid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
return DBadd_foreign_key("item_rtdata", 1, &field);
}
static int DBpatch_4030005(void)
{
if (ZBX_DB_OK <= zbx_db_execute("insert into item_rtdata (itemid,lastlogsize,state,mtime,error)"
" select i.itemid,i.lastlogsize,i.state,i.mtime,i.error"
" from items i"
" join hosts h on i.hostid=h.hostid"
" where h.status in (%d,%d) and i.flags<>%d",
HOST_STATUS_MONITORED, HOST_STATUS_NOT_MONITORED, ZBX_FLAG_DISCOVERY_PROTOTYPE))
{
return SUCCEED;
}
return FAIL;
}
static int DBpatch_4030006(void)
{
return DBdrop_field("items", "lastlogsize");
}