-- Required DDL changes for production deploy
ALTER TABLE schedule_template DROP COLUMN active;

CREATE TABLE `project_schedule_event` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `dateCreated` datetime NOT NULL,
  `lastModified` datetime NOT NULL,
  `version` int(11) NOT NULL,
  `deleted` bit(1) NOT NULL,
  `date` datetime NOT NULL,
  `description` longtext NOT NULL,
  `name` varchar(50) NOT NULL,
  `uploadRequired` bit(1) NOT NULL,
  `checkList_id` bigint(20) DEFAULT NULL,
  `creator_id` bigint(20) NOT NULL,
  `fileUpload_id` bigint(20) DEFAULT NULL,
  `projectSchedule_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `projectSchedule_id_index` (`projectSchedule_id`),
  KEY `checkList_id_index` (`checkList_id`),
  KEY `creator_id_index` (`creator_id`),
  KEY `fileUpload_id_index` (`fileUpload_id`),
  KEY `deleted_index` (`deleted`),
  CONSTRAINT `checkList_id_index` FOREIGN KEY (`checkList_id`) REFERENCES `checklist` (`id`),
  CONSTRAINT `projectSchedule_id_index` FOREIGN KEY (`projectSchedule_id`) REFERENCES `project_schedule` (`id`),
  CONSTRAINT `fileUpload_id_index` FOREIGN KEY (`fileUpload_id`) REFERENCES `file_description` (`id`),
  CONSTRAINT `creator_id_index` FOREIGN KEY (`creator_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB;

ALTER TABLE answer ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE board_message ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE board_message_board_message ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE category ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE check_plagiarism_event ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE checklist ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE checklist_answer ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE checklist_category ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE checklist_checklist_question ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE checklist_question ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE checklist_question_checklist_answer ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE checklist_template ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE checklist_template_checklist_category ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE checklist_upload ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE comment ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE comment_thread ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE event ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE file_description ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE final_seminar ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE final_seminar_active_participation ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE final_seminar_opposition ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE general_system_settings ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE group_event ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE group_event_project_schedule ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE hand_in ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE hand_in_activity ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE hand_in_feedback ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE hand_in_feedback_file_description ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE hand_in_file_description ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE log ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE log_entry ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE mail_event ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE mail_event_recipients ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE mail_event_reply_to ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE message_board ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE message_board_board_message ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE peer_queue ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE peer_request ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE peer_review ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE private_message ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE projectPartner ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_checklist ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_class ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_class_settings ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_event ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_event_student ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_event_template ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_follower ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_schedule ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_schedule_event ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE project_student ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE question ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE rating ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE recipient ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE resource ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE resource_category ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE resource_tag ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE review_rating ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE role ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE schedule_template ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE string_resource ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE tag ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE user ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE user_settings ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE username ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE web_notification ADD COLUMN version int(4) NOT NULL DEFAULT '0';
ALTER TABLE worker_data ADD COLUMN version int(4) NOT NULL DEFAULT '0';
