DROP TABLE award_contacts;

CREATE TABLE `fundraising` (
	`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
	`type` VARCHAR( 32 ) NOT NULL ,
	`name` VARCHAR( 128 ) NOT NULL ,
	`system` ENUM( 'no', 'yes' ) DEFAULT 'no' NOT NULL ,
	`goal` INT UNSIGNED NOT NULL ,
	`year` INT NOT NULL ,
	PRIMARY KEY ( `id` )
) TYPE = MYISAM ;

ALTER TABLE `fundraising` ADD UNIQUE (type,year);
INSERT INTO `fundraising` ( `id` , `type` , `name` , `system` , `goal` , `year` ) VALUES ( '', 'general', 'General Funds', 'yes', '0', '-1');
INSERT INTO `fundraising` ( `id` , `type` , `name` , `system` , `goal` , `year` ) VALUES ( '', 'awards', 'Award Sponsorships', 'yes', '0', '-1');

ALTER TABLE `award_sponsors` RENAME `sponsors` ;
ALTER TABLE `award_awards` CHANGE `award_sponsors_id` `sponsors_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'

CREATE TABLE `sponsors_logs` (
	`id` INT NOT NULL AUTO_INCREMENT ,
	`sponsors_id` INT NOT NULL ,
	`dt` DATETIME NOT NULL ,
	`users_id` INT NOT NULL ,
	`log` TEXT NOT NULL ,
	PRIMARY KEY ( `id` )
) TYPE = MYISAM ;


CREATE TABLE `sponsorships` (
	`id` INT NOT NULL AUTO_INCREMENT ,
	`sponsors_id` INT NOT NULL ,
	`fundraising_type` VARCHAR( 32 ) NOT NULL ,
	`value` INT NOT NULL ,
	`status` ENUM( 'pending', 'confirmed', 'received' ) NOT NULL ,
	`probability` INT NOT NULL ,
	`year` INT NOT NULL ,
	PRIMARY KEY ( `id` )
) TYPE = MYISAM ;

CREATE TABLE `sponsorships_levels` (
	`id` INT NOT NULL AUTO_INCREMENT ,
	`level` VARCHAR( 64 ) NOT NULL ,
	`min` INT NOT NULL ,
	`max` INT NOT NULL ,
	`description` TEXT NOT NULL ,
	`year` INT NOT NULL ,
	PRIMARY KEY ( `id` )
) TYPE = MYISAM ;
