science-ation/db/db.update.197.sql
dave ccf1b9c453 Fix an update bug. The code needs to be run to set the conference ID
before we can build a UNIQUE index on the conference id.
2010-07-13 04:25:00 +00:00

48 lines
3.1 KiB
SQL

-- Rename role columns, we know they're roles, we don't need a "role" prefix
ALTER TABLE `roles` CHANGE `roletype` `type` VARCHAR( 256 ) NOT NULL;
ALTER TABLE `roles` CHANGE `rolename` `name` VARCHAR( 256 ) NOT NULL;
-- Create space for remaining password info, will be migrated in the php script, deleted in the next db update
ALTER TABLE `accounts` ADD `passwordset` DATE NOT NULL AFTER `password`;
ALTER TABLE `accounts` ADD `oldpassword` VARCHAR( 64 ) NOT NULL AFTER `passwordset`;
-- The unique ID is now the accounts_id, call it that
ALTER TABLE `users` CHANGE `uid` `accounts_id` INT( 11 ) NOT NULL ;
-- Add comments to all the new user fields so we know which role they belong to in phpmyadmin (purely cosmetic)
ALTER TABLE `users` CHANGE `fairs_id` `fairs_id` INT(11) NOT NULL COMMENT 'fair';
ALTER TABLE `users` CHANGE `years_school` `years_school` TINYINT(4) NOT NULL COMMENT 'judge';
ALTER TABLE `users` CHANGE `years_regional` `years_regional` TINYINT(4) NOT NULL COMMENT 'judge';
ALTER TABLE `users` CHANGE `years_national` `years_national` TINYINT(4) NOT NULL COMMENT 'judge';
ALTER TABLE `users` CHANGE `willing_chair` `willing_chair` ENUM('yes','no') NOT NULL DEFAULT 'no' COMMENT 'judge';
ALTER TABLE `users` CHANGE `special_award_only` `special_award_only` ENUM('yes','no') NOT NULL DEFAULT 'no' COMMENT 'judge';
ALTER TABLE `users` CHANGE `cat_prefs` `cat_prefs` TINYTEXT NULL DEFAULT NULL COMMENT 'judge';
ALTER TABLE `users` CHANGE `div_prefs` `div_prefs` TINYTEXT NULL DEFAULT NULL COMMENT 'judge';
ALTER TABLE `users` CHANGE `divsub_prefs` `divsub_prefs` TINYTEXT NULL DEFAULT NULL COMMENT 'judge';
ALTER TABLE `users` CHANGE `languages` `languages` TINYTEXT NULL DEFAULT NULL COMMENT 'judge';
ALTER TABLE `users` CHANGE `highest_psd` `highest_psd` TINYTEXT NULL DEFAULT NULL COMMENT 'judge';
ALTER TABLE `users` CHANGE `expertise_other` `expertise_other` TINYTEXT NULL DEFAULT NULL COMMENT 'judge';
ALTER TABLE `users` CHANGE `sponsors_id` `sponsors_id` INT( 11 ) NOT NULL DEFAULT '0' COMMENT 'sponsor';
ALTER TABLE `users` CHANGE `primary` `primary` ENUM( 'no', 'yes' ) NULL DEFAULT NULL COMMENT 'sponsor';
ALTER TABLE `users` CHANGE `position` `position` VARCHAR( 64 ) NULL DEFAULT NULL COMMENT 'sponsor';
ALTER TABLE `users` CHANGE `notes` `notes` TEXT NULL DEFAULT NULL COMMENT 'sponsor';
ALTER TABLE `users` CHANGE `schools_id` `schools_id` INT( 11 ) NOT NULL COMMENT 'student';
ALTER TABLE `users` CHANGE `grade` `grade` INT( 11 ) NULL DEFAULT NULL COMMENT 'student';
-- Remove unneeded table, this linkage is in user_roles
DROP TABLE `users_conferences_link`;
-- Add conferences ID to users
ALTER TABLE `users` ADD `conferences_id` INT NOT NULL AFTER `accounts_id`;
-- Add deleted/deleted_datetime data to the accounts table
ALTER TABLE `accounts` ADD `deleted` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `superuser`;
ALTER TABLE `accounts` ADD `deleted_datetime` DATETIME NOT NULL AFTER `deleted`;
UPDATE `accounts` SET `deleted`='no';
-- Separate committee access levels into roles
INSERT INTO `roles` (`id` ,`type` ,`name`) VALUES
(12 , 'admin', 'Fair Administrator'),
(13 , 'config', 'Fair Configurator');