rename table LEGAL_REGIMEN to PROFESSIONAL_SITUATION;
alter table PROFESSIONAL_SITUATION add column INSTITUTION varchar(100) default NULL;
-- alter table PROFESSIONAL_SITUATION change column LEGAL_REGIMEN_TYPE SITUATION_TYPE varchar(100) NOT NULL default '';
alter table PROFESSIONAL_SITUATION change column REGIMEN_TYPE REGIME_TYPE varchar(100) default NULL;
alter table PROFESSIONAL_SITUATION change column LESSON_HOURS WEEKLY_LESSON_HOURS int(11) default NULL;

alter table PROFESSIONAL_SITUATION change column TOTAL_HOURS MONTHLY_HOURS double default NULL;
-- alter table PROFESSIONAL_SITUATION add column MONTHLY_HOURS double default NULL;
alter table PROFESSIONAL_SITUATION add KEY KEY_EMPLOYEE (KEY_EMPLOYEE);
-- alter table PROFESSIONAL_SITUATION add column KEY_TEACHER int(11) default NULL;

update PROFESSIONAL_SITUATION set OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.teacher.TeacherProfessionalSituation' where OJB_CONCRETE_CLASS like '%TeacherLegalRegimen%';
update PROFESSIONAL_SITUATION set OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.EmployeeProfessionalSituation' where OJB_CONCRETE_CLASS like '%EmployeeLegalRegimen%';

insert into PROFESSIONAL_SITUATION (OJB_CONCRETE_CLASS, KEY_TEACHER, BEGIN_DATE_YEAR_MONTH_DAY, END_DATE_YEAR_MONTH_DAY, SITUATION_TYPE, INSTITUTION) select 'net.sourceforge.fenixedu.domain.teacher.TeacherServiceExemption', SERVICE_EXEMPTION.KEY_TEACHER, SERVICE_EXEMPTION.START_YEAR_MONTH_DAY, SERVICE_EXEMPTION.END_YEAR_MONTH_DAY, SERVICE_EXEMPTION.TYPE, SERVICE_EXEMPTION.INSTITUTION from SERVICE_EXEMPTION;

select concat('update PROFESSIONAL_SITUATION set PROFESSIONAL_SITUATION.KEY_EMPLOYEE = ' , ass_FUNCIONARIO.ID_INTERNAL , ' where PROFESSIONAL_SITUATION.KEY_TEACHER = ' , TEACHER.ID_INTERNAL , ';') as "" from PARTY inner join TEACHER on TEACHER.KEY_PERSON = PARTY.ID_INTERNAL inner join ass_FUNCIONARIO on ass_FUNCIONARIO.KEY_PERSON = PARTY.ID_INTERNAL;

