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

# Add `company` and `phone` fields to `users` table
ALTER TABLE `mm_admin`.`users` ADD COLUMN `key` CHAR(40) NOT NULL COMMENT 'Private random sha1 string per user for security.' AFTER `id`,
 ADD COLUMN `company` VARCHAR(128) NOT NULL COMMENT 'Company user works for.' AFTER `email`,
 ADD COLUMN `phone` VARCHAR(32) NOT NULL COMMENT 'Phone number.' AFTER `company`,
 MODIFY COLUMN `state` ENUM('enabled','disabled','deleted','registering') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'enabled',
 ADD INDEX `username_index`(`username`);
UPDATE `mm_admin`.`users` SET `key` = SHA1(RAND());

# Add `registration` and `registration_alert` fields to `site` table
ALTER TABLE `mm_admin`.`site` ADD COLUMN `registration` ENUM('none','instant','email') NOT NULL DEFAULT 'none' COMMENT 'Auto registration options.' AFTER `zip_downloads`,
 ADD COLUMN `registration_alert` VARCHAR(255) NOT NULL COMMENT 'Auto registration alert email addresses.' AFTER `registration`;

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