ALTER TABLE COMPETENCE_COURSE ADD COLUMN CURRICULAR_STAGE varchar(50) NOT NULL;
UPDATE COMPETENCE_COURSE SET CURRICULAR_STAGE = "OLD";

ALTER TABLE DEGREE_CURRICULAR_PLAN ADD COLUMN CURRICULAR_STAGE varchar(50) NOT NULL;
UPDATE DEGREE_CURRICULAR_PLAN SET CURRICULAR_STAGE = "OLD";
ALTER TABLE DEGREE_CURRICULAR_PLAN ADD COLUMN KEY_DEGREE_MODULE int(11) default NULL;

ALTER TABLE CURRICULAR_COURSE ADD COLUMN CURRICULAR_STAGE varchar(50) NOT NULL;
UPDATE CURRICULAR_COURSE SET CURRICULAR_STAGE = "OLD";
ALTER TABLE CURRICULAR_COURSE ADD COLUMN CLASS_NAME varchar(255) NOT NULL default '';
UPDATE CURRICULAR_COURSE SET CLASS_NAME = "net.sourceforge.fenixedu.domain.CurricularCourse";
ALTER TABLE CURRICULAR_COURSE ADD COLUMN KEY_NEW_DEGREE_CURRICULAR_PLAN int(11) default NULL;
RENAME TABLE CURRICULAR_COURSE TO DEGREE_MODULE;
ALTER TABLE DEGREE_MODULE CHANGE COLUMN KEY_DEGREE_CURRICULAR_PLAN KEY_DEGREE_CURRICULAR_PLAN int(11) default NULL;

CREATE TABLE CONTEXT (
	ID_INTERNAL int(11) NOT NULL auto_increment,
	KEY_CURRICULAR_SEMESTER int(11) default NULL,
	KEY_DEGREE_MODULE int(11) NOT NULL,
	KEY_COURSE_GROUP int(11) NOT NULL,
	KEY_BEGIN_EXECUTION_PERIOD int(11) NOT NULL,
	KEY_END_EXECUTION_PERIOD int(11) default NULL,
	PRIMARY KEY  (ID_INTERNAL)
) TYPE=InnoDB;

CREATE TABLE COMPETENCE_COURSE_INFORMATION (
	ID_INTERNAL int(11) NOT NULL auto_increment,
	KEY_COMPETENCE_COURSE int(11) NOT NULL,
	KEY_EXECUTION_YEAR int(11) NOT NULL,
	ECTS_CREDITS double default NULL,
	BASIC tinyint(1) default '0',
	THEORETICAL_HOURS double default NULL,
	PRATICAL_HOURS double default NULL,
	THEO_PRAT_HOURS double default NULL,
	LAB_HOURS double default NULL,
	GENERAL_OBJECTIVES text,
	OPERACIONAL_OBJECTIVES text,
	PROGRAM text,
	GENERAL_OBJECTIVES_EN text,
	OPERACIONAL_OBJECTIVES_EN text,
	PROGRAM_EN text,
	PRIMARY KEY  (ID_INTERNAL)
) TYPE=InnoDB;
