DROP TABLE IF EXISTS `THESIS`;
CREATE TABLE `THESIS` (
  `ID_INTERNAL` INTEGER  NOT NULL AUTO_INCREMENT,
  `TITLE` LONGTEXT  NOT NULL,
  `THESIS_ABSTRACT` LONGTEXT,
  `KEYWORDS` TEXT,
  `COMMENT` TEXT,
  `STATE` VARCHAR(255),
  `CREATION` TIMESTAMP,
  `SUBMISSION` TIMESTAMP,
  `APPROVAL` TIMESTAMP,
  `CONFIRMATION` TIMESTAMP,
  `EVALUATION` TIMESTAMP,
  `KEY_ROOT_DOMAIN_OBJECT` INTEGER,
  `KEY_ORIENTATOR` INTEGER,
  `KEY_COORIENTATOR` INTEGER,
  `KEY_PRESIDENT` INTEGER,
  `KEY_DISSERTATION` INTEGER,
  `KEY_EXTENDED_ABSTRACT` INTEGER,
  `KEY_ENROLMENT` INTEGER,
  `KEY_DEGREE` INTEGER,
  PRIMARY KEY(`ID_INTERNAL`)
) type=InnoDB;

DROP TABLE IF EXISTS `THESIS_JURY_VOWELS`;
CREATE TABLE `THESIS_JURY_VOWELS` (
	`ID_INTERNAL` INTEGER NOT NULL AUTO_INCREMENT,
	`KEY_THESIS` INTEGER,
	`KEY_PERSON` INTEGER,
	PRIMARY KEY (`ID_INTERNAL`)
) type=InnoDB;

ALTER TABLE `FILE` 
	ADD COLUMN `KEY_DISSERTATION_THESIS` INTEGER,
	ADD COLUMN `KEY_ABSTRACT_THESIS` INTEGER;

alter table CURRICULUM_MODULE add column KEY_THESIS int(11) default null;
alter table CURRICULUM_MODULE add index (KEY_THESIS);
