update_020100.php 1.6 KB

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