From e4e79982dd3c447a4ced762a6069db553e246f59 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 28 May 2014 18:18:34 +0200 Subject: Fixed some bugs from Sateserver v05 --- apis/update.inc.php | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 apis/update.inc.php (limited to 'apis/update.inc.php') diff --git a/apis/update.inc.php b/apis/update.inc.php new file mode 100644 index 00000000..4ec94882 --- /dev/null +++ b/apis/update.inc.php @@ -0,0 +1,58 @@ += $targetVersion) + die('Up to date :-)'); + +$function = 'update_' . $currentVersion; + +if (!function_exists($function)) + die("Don't know how to update from version $currentVersion to $targetVersion :-("); + +if (!$function()) + die("Update from $currentVersion to $targetVersion failed! :-("); + +$currentVersion++; + +$ret = Database::exec("INSERT INTO property (name, value) VALUES ('webif-version', :version)", array('version' => $currentVersion), true); +if ($ret === false) + die('Writing version information back to DB failed. Next update will probably break.'); + +if ($currentVersion < $targetVersion) { + Header('Location: api.php?do=update&random=' . mt_rand()); + die("Updated to $currentVersion - press F5 to continue"); +} + +die("Updated to $currentVersion"); + +// ####################### + +// ##### 2014-05-28 +// Add dateline field to property table + +function update_1() +{ + $res = Database::simpleQuery("DESCRIBE property", array(), false); + $type = false; + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + if ($row['Field'] !== 'dateline') continue; + $type = $row['Type']; + break; + } + if ($type === false) { + Database::exec("ALTER TABLE `property` ADD `dateline` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `name` , ADD INDEX ( `dateline` )"); + } else { + Database::exec("ALTER TABLE `property` CHANGE `dateline` `dateline` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + } + return true; +} + + +// ################ \ No newline at end of file -- cgit v1.2.3-55-g7522