lychee/php/database/update_020700.php

37 lines
1.1 KiB
PHP
Raw Normal View History

<?php
/**
* Update to version 2.7.0
*/
2016-01-30 22:07:59 +00:00
use Lychee\Modules\Database;
use Lychee\Modules\Response;
// Add medium to photos
2016-01-31 14:44:54 +00:00
$query = Database::prepare($connection, "SELECT `medium` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_020700', __LINE__);
2016-01-31 14:44:54 +00:00
if ($result===false) {
$query = Database::prepare($connection, "ALTER TABLE `?` ADD `medium` TINYINT(1) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_020700', __LINE__);
if ($result===false) Response::error('Could not add medium-field to database!');
}
// Create medium folder
2014-11-06 22:21:33 +00:00
if (is_dir(LYCHEE_UPLOADS_MEDIUM)===false) {
// Only create the folder when it is missing
if (@mkdir(LYCHEE_UPLOADS_MEDIUM)===false) {
Log::error($connection, 'update_020700', __LINE__, 'Could not create medium-folder');
Response::error('Could not create medium-folder!');
}
2014-11-06 22:21:33 +00:00
}
// Set version
if (Database::setVersion($connection, '020700')===false) Response::error('Could not update version of database!');
?>