update_020100.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. ###
  3. # @name Update to version 2.1
  4. # @copyright 2015 by Tobias Reich
  5. ###
  6. if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
  7. $query = Database::prepare($database, "SELECT `tags` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
  8. if(!$database->query($query)) {
  9. $query = Database::prepare($database, "ALTER TABLE `?` ADD `tags` VARCHAR( 1000 ) NULL DEFAULT ''", array(LYCHEE_TABLE_PHOTOS));
  10. $result = $database->query($query);
  11. if (!$result) {
  12. Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
  13. return false;
  14. }
  15. }
  16. $query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'dropboxKey' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
  17. $result = $database->query($query);
  18. if ($result->num_rows===0) {
  19. $query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('dropboxKey', '')", array(LYCHEE_TABLE_SETTINGS));
  20. $result = $database->query($query);
  21. if (!$result) {
  22. Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
  23. return false;
  24. }
  25. }
  26. $query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'version' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
  27. $result = $database->query($query);
  28. if ($result->num_rows===0) {
  29. $query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('version', '020100')", array(LYCHEE_TABLE_SETTINGS));
  30. $result = $database->query($query);
  31. if (!$result) {
  32. Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
  33. return false;
  34. }
  35. } else {
  36. if (Database::setVersion($database, '020100')===false) return false;
  37. }
  38. ?>