insert into COURSE_LOAD_SHIFT (KEY_COURSE_LOAD, KEY_SHIFT) select COURSE_LOAD.ID_INTERNAL, SHIFT.ID_INTERNAL from SHIFT inner join EXECUTION_COURSE on EXECUTION_COURSE.ID_INTERNAL = SHIFT.KEY_DISCIPLINA_EXECUCAO inner join COURSE_LOAD on COURSE_LOAD.KEY_EXECUTION_COURSE = EXECUTION_COURSE.ID_INTERNAL where COURSE_LOAD.TYPE = SHIFT.TIPO;

alter table SHIFT drop column KEY_DISCIPLINA_EXECUCAO;
alter table LESSON drop column TIPO;

select concat('update LESSON_INSTANCE set KEY_COURSE_LOAD = ' , COURSE_LOAD_SHIFT.KEY_COURSE_LOAD , ' where KEY_LESSON = ' , LESSON.ID_INTERNAL , ';') as "" from LESSON inner join SHIFT on LESSON.KEY_SHIFT = SHIFT.ID_INTERNAL inner join COURSE_LOAD_SHIFT on COURSE_LOAD_SHIFT.KEY_SHIFT = SHIFT.ID_INTERNAL;
