/
db_update.php
57 lines (52 loc) · 2.02 KB
/
db_update.php
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
<?php
/**
* Make sure the database is at the most recent version
*
* @license GPL
*
* @package MythWeb
*
/**/
// What *should* the database version be?
define('WebDBSchemaVer', 3);
// What version does the database think it is?
$db_vers = intval(setting('WebDBSchemaVer'));
if ($db_vers < 0)
$db_vers = 0;
// The database is too new
if ($db_vers > WebDBSchemaVer)
trigger_error("Current database version of $db_vers is newer than"
." the code base version ".WebDBSchemaVer,
FATAL);
// Older database that needs to be upgraded
if ($db_vers < WebDBSchemaVer) {
switch ($db_vers) {
// No version, no database
case 0:
$db->query('DROP TABLE IF EXISTS mythweb_sessions');
$db->query('CREATE TABLE mythweb_sessions (
id VARCHAR(128) PRIMARY KEY NOT NULL DEFAULT "",
modified TIMESTAMP,
data BLOB NOT NULL,
INDEX (modified)
)');
setting('WebDBSchemaVer', null, ++$db_vers, false);
// Moving settings into the database
case 1:
setting('WebPrefer_Channum', null, 1, false);
setting('WebDBSchemaVer', null, ++$db_vers, false);
// Add default width for recording details if they have not been set yet
case 2:
$width = intval(setting('WebFLV_w'));
if ($width < 1) {
setting('WebFLV_w', null, 320, false);
} elseif ($width < 160) {
setting('WebFLV_w', null, 160, false);
}
setting('WebDBSchemaVer', null, ++$db_vers, false);
// All other numbers should run their changes sequentially
#case 3:
# # do something to upgrade the database here
# $db_vers++;
}
}