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
|
<?php
$res = array();
$res[] = tableCreate('clientlog', "
`logid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`dateline` int(10) unsigned NOT NULL,
`logtypeid` varchar(30) NOT NULL,
`clientip` varchar(40) NOT NULL,
`machineuuid` varchar(36) CHARACTER SET ascii DEFAULT NULL,
`description` varchar(255) NOT NULL,
`extra` text NOT NULL,
PRIMARY KEY (`logid`),
KEY `dateline` (`dateline`),
KEY `logtypeid` (`logtypeid`,`dateline`),
KEY `clientip` (`clientip`,`dateline`),
KEY `machineuuid` (`machineuuid`,`dateline`)
");
// Update path
if (!tableHasColumn('clientlog', 'machineuuid')) {
$ret = Database::exec('ALTER TABLE clientlog'
. ' ADD COLUMN `machineuuid` varchar(36) CHARACTER SET ascii DEFAULT NULL AFTER clientip,'
. ' ADD INDEX `machineuuid` (`machineuuid`,`dateline`)');
if ($ret === false) {
finalResponse(UPDATE_FAILED, 'Adding machineuuid to clientlog failed: ' . Database::lastError());
}
$res[] = UPDATE_DONE;
}
// Create response for browser
if (in_array(UPDATE_DONE, $res)) {
finalResponse(UPDATE_DONE, 'Tables created successfully');
}
finalResponse(UPDATE_NOOP, 'Everything already up to date');
|