##----------------------------------------------------------------------------------#
 # MusicMiner Web Server															#
 # Name:		source/app/sql/upgrade_0-8-4_to_0-9-0.sql							#
 # Author:		Jesse J Morrow	(jesse@jessejmorrow.com)							#
 # Created:		2007-10-22															#
 # Updated:		2007-11-04															#
 # Compat:		MySQL 5																#
 # Copyright:	Copyright 2007 Soundminer Inc.										#
 # Purpose:		Upgrade the installed MusicMiner databases.							#
 # Version:		0.8.4 to 0.9.0														#
 #----------------------------------------------------------------------------------##

# Add `asset_key` to `assets` table for anonymous audition security
ALTER TABLE `mm_admin`.`assets` ADD COLUMN `asset_key` CHAR(32) NOT NULL COMMENT 'Random md5 hash used for access security.' AFTER `track_id`;
UPDATE `mm_admin`.`assets` SET `asset_key` = MD5(RAND());

# Add comment to `users`.`db_id` that now has extended semantics to cover folder IDs
ALTER TABLE `mm_admin`.`users` MODIFY COLUMN `db_id` INTEGER NOT NULL DEFAULT 0 COMMENT '0: all, >0:  db_id, <0: -folder_id';

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