##----------------------------------------------------------------------------------#
 # MusicMiner Web Server															#
 # Name:		source/app/sql/upgrade_1-0-4_to_1-0-5.sql							#
 # Author:		Jesse J Morrow	(jesse@jessejmorrow.com)							#
 # Created:		2008-09-25															#
 # Updated:		2008-12-02															#
 # Compat:		MySQL 5																#
 # Copyright:	Copyright 2008 Soundminer Inc.										#
 # Purpose:		Upgrade the installed MusicMiner databases.							#
 # Version:		1.0.4 to 1.0.5														#
 #----------------------------------------------------------------------------------##

# Add index to `log` table
ALTER TABLE `mm_admin`.`log` ADD INDEX `user_event_index`(`user_id`, `event`);

# Remove legacy `weights` column from `sites` table
ALTER TABLE `mm_admin`.`site` DROP COLUMN `weights`;

# Fix effects of deleting group folder, which should have been disallowed
UPDATE `mm_admin`.`groups`, `mm_admin`.`folders` SET `folders`.`folder_id` = 0, `folders`.`path` = '/' WHERE `groups`.`folder_id` = `folders`.`id`;
UPDATE `mm_admin`.`users`, `mm_admin`.`folders` SET `folders`.`folder_id` = 0, `folders`.`path` = '/' WHERE `users`.`folder_id` = `folders`.`id`;

# Update version fields
UPDATE `mm_admin`.`schema` SET `db_ver` = '1.0.5';