2015-05-10 21:01:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
###
|
|
|
|
# @name Update to version 3.0.1
|
|
|
|
# @copyright 2015 by Tobias Reich
|
|
|
|
###
|
|
|
|
|
|
|
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
|
|
|
|
|
|
|
# Change length of photo title
|
2016-01-24 21:14:20 +00:00
|
|
|
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `title` `title` VARCHAR( 100 ) NOT NULL DEFAULT ''", array(LYCHEE_TABLE_PHOTOS));
|
|
|
|
$result = $connection->query($query);
|
2015-05-10 21:01:07 +00:00
|
|
|
if (!$result) {
|
2016-01-24 21:14:20 +00:00
|
|
|
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
2015-05-10 21:01:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Change length of album title
|
2016-01-24 21:14:20 +00:00
|
|
|
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `title` `title` VARCHAR( 100 ) NOT NULL DEFAULT ''", array(LYCHEE_TABLE_ALBUMS));
|
|
|
|
$result = $connection->query($query);
|
2015-05-10 21:01:07 +00:00
|
|
|
if (!$result) {
|
2016-01-24 21:14:20 +00:00
|
|
|
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
2015-05-10 21:01:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-14 15:20:33 +00:00
|
|
|
# Add album sorting to settings
|
2016-01-24 21:14:20 +00:00
|
|
|
$query = Database::prepare($connection, "SELECT `key` FROM `?` WHERE `key` = 'sortingAlbums' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
|
|
|
|
$result = $connection->query($query);
|
2015-05-14 15:20:33 +00:00
|
|
|
if ($result->num_rows===0) {
|
2016-01-24 21:14:20 +00:00
|
|
|
$query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('sortingAlbums', 'ORDER BY id DESC')", array(LYCHEE_TABLE_SETTINGS));
|
|
|
|
$result = $connection->query($query);
|
2015-05-14 15:20:33 +00:00
|
|
|
if (!$result) {
|
2016-01-24 21:14:20 +00:00
|
|
|
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
2015-05-14 15:20:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-14 15:47:17 +00:00
|
|
|
# Rename sorting to sortingPhotos
|
2016-01-24 21:14:20 +00:00
|
|
|
$query = Database::prepare($connection, "UPDATE ? SET `key` = 'sortingPhotos' WHERE `key` = 'sorting' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
|
|
|
|
$result = $connection->query($query);
|
2015-05-14 15:47:17 +00:00
|
|
|
if (!$result) {
|
2016-01-24 21:14:20 +00:00
|
|
|
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
2015-05-14 15:47:17 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-14 18:43:51 +00:00
|
|
|
# Add identifier to settings
|
2016-01-24 21:14:20 +00:00
|
|
|
$query = Database::prepare($connection, "SELECT `key` FROM `?` WHERE `key` = 'identifier' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
|
|
|
|
$result = $connection->query($query);
|
2015-05-14 18:43:51 +00:00
|
|
|
if ($result->num_rows===0) {
|
|
|
|
$identifier = md5(microtime(true));
|
2016-01-24 21:14:20 +00:00
|
|
|
$query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('identifier', '?')", array(LYCHEE_TABLE_SETTINGS, $identifier));
|
|
|
|
$result = $connection->query($query);
|
2015-05-14 18:43:51 +00:00
|
|
|
if (!$result) {
|
2016-01-24 21:14:20 +00:00
|
|
|
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
2015-05-14 18:43:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-10 21:01:07 +00:00
|
|
|
# Set version
|
2016-01-24 21:14:20 +00:00
|
|
|
if (Database::setVersion($connection, '030001')===false) return false;
|
2015-05-10 21:01:07 +00:00
|
|
|
|
|
|
|
?>
|