##----------------------------------------------------------------------------------#
 # MusicMiner Web Server															#
 # Name:		source/app/sql/upgrade_0-7-1_to_0-7-2.sql							#
 # Author:		Jesse J Morrow	(jesse@jessejmorrow.com)							#
 # Created:		2007-08-08															#
 # Updated:		2007-08-12															#
 # Compat:		MySQL 5																#
 # Copyright:	Copyright 2007 Soundminer Inc.										#
 # Purpose:		Upgrade the installed MusicMiner databases.							#
 # Version:		0.7.1 to 0.7.2														#
 #----------------------------------------------------------------------------------##

# Fix default Download Summary report
UPDATE `mm_admin`.`reports` SET `title` = 'Download Summary', `description` = '', `time` = 'all', `begin` = NULL, `end` = NULL, `users` = '0', `tables` = '[{\"type\":\"summary\",\"title\":\"Top Categories\",\"events\":[\"download\"],\"groups\":[[\"Category\",\"a_category\",\"\",1,1]],\"fields\":[[\"# Downloads\",\"id\",\"desc\",null,\"count\"],[\"# Assets\",\"a_id\",\"desc\",null,\"dcount\"]],\"where\":[],\"limit\":null,\"grand\":null},{\"type\":\"summary\",\"title\":\"Top Libraries\",\"events\":[\"download\"],\"groups\":[[\"Library\",\"a_library\",\"\",1,1]],\"fields\":[[\"# Downloads\",\"id\",\"desc\",null,\"count\"],[\"# Assets\",\"a_id\",\"desc\",null,\"dcount\"]],\"where\":[],\"limit\":null,\"grand\":null},{\"type\":\"summary\",\"title\":\"Top Albums\",\"events\":[\"download\"],\"groups\":[[\"Album\",\"a_cdtitle\",\"\",1,1]],\"fields\":[[\"# Downloads\",\"id\",\"desc\",null,\"count\"],[\"# Assets\",\"a_id\",\"desc\",null,\"dcount\"]],\"where\":[],\"limit\":null,\"grand\":null},{\"type\":\"summary\",\"title\":\"Top Users\",\"events\":[\"download\"],\"groups\":[[\"User\",\"user\",\"\",1,1]],\"fields\":[[\"# Downloads\",\"id\",\"desc\",null,\"count\"],[\"# Assets\",\"a_id\",\"desc\",null,\"dcount\"]],\"where\":[],\"limit\":null,\"grand\":null}]' WHERE `id` = '3';

# Update base `sort_tracks` and `sort_albums` with new JSON format
UPDATE `mm_admin`.`perms` SET `sort_tracks` = '{\"Relevance\":\"ascend\",\"Library\":\"ascend\",\"Volume\":\"descend\",\"Track\":\"ascend\"}' WHERE `id` = '1';
UPDATE `mm_admin`.`perms` SET `sort_albums` = '{\"Library\":\"ascend\",\"Volume\":\"descend\"}' WHERE `id` = '1';

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