<?php
/**
 * Upgrades the database from version 1.4.1 to version 1.5.0.
 * DO NOT call this directly, it will fail.
 * To be included from classes/core/updater.class.php.
 * Assumes that logging has already been init()ed. Log class will throw ServerException if not.
 */

Log::write(Log::LOGLEVEL_INFO, "In updater, from 1.4.1 to 1.5.0");

Log::write(Log::LOGLEVEL_DEBUG, "...adding isavailable column to screens table...");
database::query('ALTER TABLE `screen` ADD `isavailable` BOOLEAN NOT NULL DEFAULT TRUE AFTER `isstandard`;');

Log::write(Log::LOGLEVEL_DEBUG, "...setting isavailable to 1 for standard screens, 0 for optimizations...");
database::query('UPDATE `screen` SET `isavailable`=`isstandard`;');

Log::write(Log::LOGLEVEL_DEBUG, "...adding star rating column to crystal table...");
database::query("ALTER TABLE `crystal` ADD `starrating` TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER `isfished`, ADD INDEX (`starrating`); ");

Log::write(Log::LOGLEVEL_DEBUG, "...adding star rating column to crystal table...");
database::query("ALTER TABLE `dataset` ADD `starrating` TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER `pdbdepositionid`, ADD INDEX (`starrating`); ");

Log::write(Log::LOGLEVEL_INFO, "...done");

