Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dbupgrade_3040.c « zbxdbupgrade « libs « src - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5e6635e6711d1ac3163093ca24629e0a28a8fcef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
** Zabbix
** Copyright (C) 2001-2019 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/

#include "common.h"
#include "db.h"
#include "dbupgrade.h"

/*
 * 3.4 maintenance database patches
 */

#ifndef HAVE_SQLITE3

static int	DBpatch_3040000(void)
{
	return SUCCEED;
}

extern int	DBpatch_3020001(void);

static int	DBpatch_3040001(void)
{
	return DBpatch_3020001();
}

static int	DBpatch_3040002(void)
{
	return DBdrop_foreign_key("sessions", 1);
}

static int	DBpatch_3040003(void)
{
	return DBdrop_index("sessions", "sessions_1");
}

static int	DBpatch_3040004(void)
{
	return DBcreate_index("sessions", "sessions_1", "userid,status,lastaccess", 0);
}

static int	DBpatch_3040005(void)
{
	const ZBX_FIELD	field = {"userid", NULL, "users", "userid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};

	return DBadd_foreign_key("sessions", 1, &field);
}

int	DBpatch_3040006(void)
{
	if (FAIL == DBindex_exists("problem", "problem_3"))
		return DBcreate_index("problem", "problem_3", "r_eventid", 0);

	return SUCCEED;
}

int	DBpatch_3040007(void)
{
#ifdef HAVE_MYSQL	/* MySQL automatically creates index and might not remove it on some conditions */
	if (SUCCEED == DBindex_exists("problem", "c_problem_2"))
		return DBdrop_index("problem", "c_problem_2");
#endif
	return SUCCEED;
}

#endif

DBPATCH_START(3040)

/* version, duplicates flag, mandatory flag */

DBPATCH_ADD(3040000, 0, 1)
DBPATCH_ADD(3040001, 0, 0)
DBPATCH_ADD(3040002, 0, 0)
DBPATCH_ADD(3040003, 0, 0)
DBPATCH_ADD(3040004, 0, 0)
DBPATCH_ADD(3040005, 0, 0)
DBPATCH_ADD(3040006, 0, 0)
DBPATCH_ADD(3040007, 0, 0)

DBPATCH_END()