##----------------------------------------------------------------------------------#
 # MusicMiner Web Server															#
 # Name:		source/app/sql/upgrade_1.2.0.9.sql									#
 # Author:		Jesse J Morrow	(jesse@jessejmorrow.com)							#
 # Created:		2010-02-04															#
 # Updated:		2010-02-04															#
 # Compat:		MySQL 5																#
 # Copyright:	Copyright 2010 Soundminer Inc.										#
 # Purpose:		Upgrade the installed MusicMiner databases.							#
 # Version:		1.2.0.8 to 1.2.0.9													#
 #----------------------------------------------------------------------------------##

# Fix root folder settings (done in 1.2.0, but found bug causing newly created users/groups not have proper settings)
UPDATE `mm_admin`.`folders`, `mm_admin`.`users` SET `owner_id` = `users`.`id`, `folders`.`type` = 'private', `o_access` = 'read,add,modify,delete', `s_access` = '', `root_id` = `folders`.`id`, `path` = CONCAT('/', `users`.`user`,':', `users`.`id`, '/'), `folders`.`name` = `users`.`user` WHERE `folders`.`id` = `users`.`folder_id`;
UPDATE `mm_admin`.`folders`, `mm_admin`.`groups` SET `owner_id` = -`groups`.`id`, `folders`.`type` = 'private', `o_access` = 'read,add,modify,delete', `s_access` = '', `root_id` = `folders`.`id`, `path` = CONCAT('/', `groups`.`name`, ':', -`groups`.`id`, '/'), `folders`.`name` = `groups`.`name` WHERE `folders`.`id` = `groups`.`folder_id`;

#-----------------------------------------------------------------------------
# Versions
#-----------------------------------------------------------------------------

# Update version fields
UPDATE `mm_admin`.`schema` SET `db_ver` = '1.2.0.9', `sm_ver` = '1.2.0.9';