alter table crd_OTHER_TYPE_CREDIT_LINE rename to CREDIT_LINE;

alter table CREDIT_LINE add column OJB_CONCRETE_CLASS varchar(250) not null;

update CREDIT_LINE set OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.credits.OtherTypeCreditLine';

alter table CREDIT_LINE add column POSITION text default null;
alter table CREDIT_LINE add column START date NOT NULL default '0000-00-00';
alter table CREDIT_LINE add column END date NOT NULL default '0000-00-00';

insert into CREDIT_LINE (KEY_TEACHER, POSITION, START, END, CREDITS, KEY_ROOT_DOMAIN_OBJECT, OJB_CONCRETE_CLASS)
select KEY_TEACHER, POSITION, START, END, CREDITS, 1, 'net.sourceforge.fenixedu.domain.credits.ManagementPositionCreditLine'
from crd_MANAGEMENT_POSITION_CREDIT_LINE;

drop table crd_MANAGEMENT_POSITION_CREDIT_LINE;


alter table PAYMENT_TRANSACTION rename to TRANSACTION;

alter table TRANSACTION add column KEY_REIMBURSEMENT_GUIDE_ENTRY int(11) default NULL;

insert into TRANSACTION (ID_INTERNAL, VALUE_BIG_DECIMAL, TRANSACTION_DATE_DATE_TIME, REMARKS, PAYMENT_TYPE, TRANSACTION_TYPE, WAS_INTERNAL_BALANCE, KEY_RESPONSIBLE_PERSON, KEY_REIMBURSEMENT_GUIDE_ENTRY, KEY_PERSON_ACCOUNT, OJB_CONCRETE_CLASS, KEY_ROOT_DOMAIN_OBJECT)
select ID_INTERNAL, VALUE_BIG_DECIMAL, TRANSACTION_DATE_DATE_TIME, REMARKS, PAYMENT_TYPE, TRANSACTION_TYPE, WAS_INTERNAL_BALANCE, KEY_RESPONSIBLE_PERSON, KEY_REIMBURSEMENT_GUIDE_ENTRY, KEY_PERSON_ACCOUNT, OJB_CONCRETE_CLASS, KEY_ROOT_DOMAIN_OBJECT
from REIMBURSEMENT_TRANSACTION;

drop table REIMBURSEMENT_TRANSACTION;


alter table TESTS_TEST_ELEMENT rename to NEW_TEST_ELEMENT;
alter table ACCOUNTING_EVENT rename to EVENT;
alter table RESULT rename to RESEARCH_RESULT;
alter table RESEARCH_EVENT_EDITION rename to EVENT_EDITION;
alter table CREDITS_DISMISSAL rename to CREDITS;
alter table crd_TEACHER_INSTITUTION_WORK_TIME rename to TEACHER_INSTITUTION_WORK_TIME;
alter table ID_DOCUMENT_TYPE rename to ID_DOCUMENT_TYPE_OBJECT;
alter table SEMINARY_CURRICULARCOURSE rename to COURSE_EQUIVALENCY;
alter table TESTS_PRESENTATION_MATERIAL rename to NEW_PRESENTATION_MATERIAL;
alter table PUBLICATION_DATA rename to PUBLICATION;
alter table FAQ_SECTION rename to F_A_Q_SECTION;
alter table TESTS_GROUP_ELEMENT rename to NEW_GROUP_ELEMENT;
alter table RESEARCH_ACTIVITY_PARTICIPATION rename to PARTICIPATION;
alter table SEMINARY_THEME rename to THEME;
alter table crd_TEACHER_DEGREE_FINAL_PROJECT_STUDENT rename to TEACHER_DEGREE_FINAL_PROJECT_STUDENT;
alter table ATTEND rename to ATTENDS;
alter table SEMINARY_CASESTUDY rename to CASE_STUDY;
alter table PUBLICATION_ATTRIBUTE rename to PUBLICATION_TYPE_ATTRIBUTE;
alter table PERIOD rename to OCCUPATION_PERIOD;
alter table TESTS_ANSWER rename to NEW_ANSWER;
alter table RESEARCH_PROJECT rename to PROJECT;
alter table FINAL_DEGREE_WORK_GROUP_PROPOSAL rename to GROUP_PROPOSAL;
alter table ACCOUNTING_ENTRY rename to ENTRY;
alter table RESEARCH_COOPERATION rename to COOPERATION;
alter table GROUPING_EXECUTION_COURSE rename to EXPORT_GROUPING;
alter table RESEARCH_PROJECT_PARTICIPATION rename to PROJECT_PARTICIPATION;
alter table SEMINARYCANDIDACY_SEMINARYCASESTUDY rename to CASE_STUDY_CHOICE;
alter table MARKSHEET rename to MARK_SHEET;
alter table ass_FUNCIONARIO_HISTORICO rename to EMPLOYEE_HISTORIC;
alter table TUTOR_SHIP rename to TUTOR;
alter table XML_DOCUMENTS rename to QUESTION;
alter table TESTS_PERMISSION_UNIT rename to NEW_PERMISSION_UNIT;
alter table TESTS_TEST_GROUP rename to NEW_TEST_GROUP;
alter table CONVOKE rename to VIGILANCY;
alter table PROFESSORSHIPS rename to PROFESSORSHIP;
alter table SEMINARY_MODALITY rename to MODALITY;
alter table CLASS rename to SCHOOL_CLASS;
alter table FINAL_DEGREE_WORK_PROPOSAL rename to PROPOSAL;
alter table FAQ_ENTRY rename to F_A_Q_ENTRY;
alter table FINAL_DEGREE_WORK_SCHEDULEING rename to SCHEDULEING;
alter table DISTRIBUTED_TESTS rename to DISTRIBUTED_TEST;
alter table RESEARCH_PROJECT_RESEARCH_EVENT_ASSOCIATION rename to PROJECT_EVENT_ASSOCIATION;
alter table ass_STATUS rename to STATUS_ASSIDUIDADE;
alter table FINAL_DEGREE_WORK_GROUP_STUDENT rename to GROUP_STUDENT;
alter table RESEARCH_PRIZE rename to PRIZE;
alter table ass_CENTRO_CUSTO rename to COST_CENTER;
alter table TESTS rename to TEST;
alter table TESTS_CORRECTOR rename to NEW_CORRECTOR;
alter table ass_FUNCIONARIO rename to EMPLOYEE;


delete from OJB_HL_SEQ;
