update_020700.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Update to version 2.7.0
  4. */
  5. use Lychee\Modules\Database;
  6. use Lychee\Modules\Response;
  7. // Add medium to photos
  8. $query = Database::prepare($connection, "SELECT `medium` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
  9. $result = Database::execute($connection, $query, 'update_020700', __LINE__);
  10. if ($result===false) {
  11. $query = Database::prepare($connection, "ALTER TABLE `?` ADD `medium` TINYINT(1) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_PHOTOS));
  12. $result = Database::execute($connection, $query, 'update_020700', __LINE__);
  13. if ($result===false) Response::error('Could not add medium-field to database!');
  14. }
  15. // Create medium folder
  16. if (is_dir(LYCHEE_UPLOADS_MEDIUM)===false) {
  17. // Only create the folder when it is missing
  18. if (@mkdir(LYCHEE_UPLOADS_MEDIUM)===false) {
  19. Log::error($connection, 'update_020700', __LINE__, 'Could not create medium-folder');
  20. Response::error('Could not create medium-folder!');
  21. }
  22. }
  23. // Set version
  24. if (Database::setVersion($connection, '020700')===false) Response::error('Could not update version of database!');
  25. ?>