update_030001.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. ###
  3. # @name Update to version 3.0.1
  4. # @copyright 2015 by Tobias Reich
  5. ###
  6. if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
  7. # Change length of photo title
  8. $query = Database::prepare($database, "ALTER TABLE `?` CHANGE `title` `title` VARCHAR( 100 ) NOT NULL DEFAULT ''", array(LYCHEE_TABLE_PHOTOS));
  9. $result = $database->query($query);
  10. if (!$result) {
  11. Log::error($database, 'update_030001', __LINE__, 'Could not update database (' . $database->error . ')');
  12. return false;
  13. }
  14. # Change length of album title
  15. $query = Database::prepare($database, "ALTER TABLE `?` CHANGE `title` `title` VARCHAR( 100 ) NOT NULL DEFAULT ''", array(LYCHEE_TABLE_ALBUMS));
  16. $result = $database->query($query);
  17. if (!$result) {
  18. Log::error($database, 'update_030001', __LINE__, 'Could not update database (' . $database->error . ')');
  19. return false;
  20. }
  21. # Add album sorting to settings
  22. $query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'sortingAlbums' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
  23. $result = $database->query($query);
  24. if ($result->num_rows===0) {
  25. $query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('sortingAlbums', 'ORDER BY id DESC')", array(LYCHEE_TABLE_SETTINGS));
  26. $result = $database->query($query);
  27. if (!$result) {
  28. Log::error($database, 'update_030001', __LINE__, 'Could not update database (' . $database->error . ')');
  29. return false;
  30. }
  31. }
  32. # Rename sorting to sortingPhotos
  33. $query = Database::prepare($database, "UPDATE ? SET `key` = 'sortingPhotos' WHERE `key` = 'sorting' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
  34. $result = $database->query($query);
  35. if (!$result) {
  36. Log::error($database, 'update_030001', __LINE__, 'Could not update database (' . $database->error . ')');
  37. return false;
  38. }
  39. # Set version
  40. if (Database::setVersion($database, '030001')===false) return false;
  41. ?>