update_030102.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Update to version 3.1.2
  4. */
  5. use Lychee\Modules\Database;
  6. use Lychee\Modules\Response;
  7. // Change type of the album id field
  8. $query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `album` `album` BIGINT UNSIGNED NOT NULL", array(LYCHEE_TABLE_PHOTOS));
  9. $result = Database::execute($connection, $query, 'update_030102', __LINE__);
  10. if ($result===false) Response::error('Could not change type of the album id field!');
  11. // Add index to the album id field
  12. $query = Database::prepare($connection, "ALTER TABLE `?` ADD INDEX `Index_album` (`album`)", array(LYCHEE_TABLE_PHOTOS));
  13. $result = Database::execute($connection, $query, 'update_030102', __LINE__);
  14. if ($result===false) Response::error('Could not add index to the album id field!');
  15. // Add index to the star field
  16. $query = Database::prepare($connection, "ALTER TABLE `?` ADD INDEX `Index_star` (`star`)", array(LYCHEE_TABLE_PHOTOS));
  17. $result = Database::execute($connection, $query, 'update_030102', __LINE__);
  18. if ($result===false) Response::error('Could not add index to the star field!');
  19. // Change type of the checksum field
  20. $query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `checksum` `checksum` CHAR(40) NULL DEFAULT NULL", array(LYCHEE_TABLE_PHOTOS));
  21. $result = Database::execute($connection, $query, 'update_030102', __LINE__);
  22. if ($result===false) Response::error('Could not change type of the checksum field!');
  23. // Change type of the thumbUrl field
  24. $query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `thumbUrl` `thumbUrl` CHAR(37) NOT NULL", array(LYCHEE_TABLE_PHOTOS));
  25. $result = Database::execute($connection, $query, 'update_030102', __LINE__);
  26. if ($result===false) Response::error('Could not change type of the thumbUrl field!');
  27. // Change type of the id field
  28. $query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `id` `id` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_PHOTOS));
  29. $result = Database::execute($connection, $query, 'update_030102', __LINE__);
  30. if ($result===false) Response::error('Could not change type of the id field!');
  31. // Change type of the id field
  32. $query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `id` `id` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_ALBUMS));
  33. $result = Database::execute($connection, $query, 'update_030102', __LINE__);
  34. if ($result===false) Response::error('Could not change type of the id field!');
  35. // Set version
  36. //if (Database::setVersion($connection, '030102')===false) Response::error('Could not update version of database!');
  37. ?>