Squash and fix migrations so they run against an empty schema ()

This is one requirement in bringing  to reality.

Currently there are some 450 migration scripts that have been added over the past 11 years. Unfortunately some of these migration scripts have some defects. Either from the fact that they are very old and from another database engine (MySQL vs currently MariaDB), make assumptions about the database name, or its contents. Due to these defects trying to bring an empty schema up-to-date by running all migrations will fail with [372](ff4c5b58b4/core/src/main/resources/db/migration/V372__update_and_insert_grading_criterion_template_master.sql) being the main blocker.

If it is not possible to bring an empty schema up-to-date it is a major hindrance to the plan of automatically deploying test servers for every pull request (). These changes makes it possible to bring an empty schema up to the latest version by squashing all migration scripts to a single new baseline with the necessary fixes to work on an empty schema.

There is a downside with the way it accomplishes this, it requires any non-empty schema to already be at version [392.2](ff4c5b58b4/core/src/main/resources/db/migration/V392_2__reflection_comment_by_supervisor.sql). [Flyway](https://www.red-gate.com/products/flyway/), the product we use for database migrations, does not support new baseline scripts in the free version, only in the paid edition. To get around this, Flyway is tricked into thinking the database has never used Flyway before by changing which database table stores the information about applied migrations. This is the reason the database has to be at the latest (392.2) version before deploying the new version of SciPro that include this change, because Flyway will have no way to see which of the old migrations have been applied.

An alternative would be to fix the old migrations so they would work on an empty schema. However, since every migration script is checksummed to see that the applied version is the correct one every database would have to be ["repaired"](https://documentation.red-gate.com/fd/repair-184127461.html) to update its checksums. This choice was not taken for two reasons:

 * It would require manual work in the database before deploying the new version of SciPro with the fixed migrations, similar to the requirement to first deploy the version of SciPro that includes the 392.2 migration.
 * Running all the migrations taken a lot of time, especially the new [391](ff4c5b58b4/core/src/main/resources/db/migration/V391__harmonize_table_attribute_name.sql). Squashing all migrations avoid this and makes spinning up new databases very quick

## How to test with an existing schema
1. Deploy commit [ff4c5b58b40db5fcb7754c259c3854194668c1e1](ff4c5b58b4) (current `develop` branch as of 2024-11-22)
2. Start the system to apply migrations up to and including 392.2
3. Switch to this branch
4. Start the system and see that the database will be considered baselined at version 2
5. Click around in the system and see that it still works

## How to test with an empty schema
1. Empty your database schema
2. Switch to this branch
3. Deploy the system
4. See that it migrates the schema and creates all the necessary tables
5. Log in as `admin@example.com` that is created by the `DataInitializer`

Reviewed-on: 
Reviewed-by: Tom Zhao <tom.zhao@dsv.su.se>
Co-authored-by: Andreas Svanberg <andreass@dsv.su.se>
Co-committed-by: Andreas Svanberg <andreass@dsv.su.se>
This commit is contained in:
Andreas Svanberg 2024-12-02 10:31:20 +01:00 committed by Tom Zhao
parent 8a657b21dd
commit a2330ce2d5
451 changed files with 2920 additions and 15662 deletions
core/src/main
java/se/su/dsv/scipro
resources/db/migration
V100__description_to_checklists.sqlV101__made_type_not_null_in_file_description_until_migration_is_done.sqlV102__added_final_seminar_created_event.sqlV103__file_description_clean_up.sqlV104__removed_target_last_modified_from_file_description.sqlV105__remove_supervisor_checklists.sqlV106__remove_supervisor_checklist_templates.sqlV107__deletable_project_files.sqlV108__adding_phd_stuff.sqlV109__phd_tables_utf8.sqlV10__grading_report_for_bachelor.sqlV110__copy_daisy_start_date_to_date_created_and_drop_it.sqlV111__cascade_in_database_to_handle_hibernate_misses.sqlV112__project_type_modules.sqlV113__renamed_phd_to_study_plan.sqlV114__drop_project_type_from_project_partner.sqlV115_10__change_final_seminar_active_participation_to_user.sqlV115_11__change_milestone_to_user.sqlV115_12__change_head_supervisor_to_user.sqlV115_13__change_project_follower_to_user.sqlV115_14__changed_peer_review_to_user.sqlV115_15__changed_peer_request_to_user.sqlV115_16__changed_application_period_exemption_to_user.sqlV115_17__changed_idea_participation_to_user.sqlV115_18__changed_match_to_user.sqlV115_19__changed_target_to_user.sqlV115_1__migrate_student_data_to_user.sqlV115_20__changed_final_seminar_examiner_to_user.sqlV115_21__clean_up.sqlV115_2__migrate_language_to_user.sqlV115_3__migrate_research_area_to_user.sqlV115_4__migrate_unit_to_user.sqlV115_5__migrated_roles_to_new_table.sqlV115_6__made_project_authors_be_user_not_student.sqlV115_7__change_grading_report_to_user.sqlV115_8__change_final_seminar_respondent_to_user.sqlV115_9__change_final_seminar_opposition_to_user.sqlV116__removing_unused_attributes.sqlV117__removing_unused_attributes.sqlV118__add_credits_to_grading_report_template.sqlV119__removing_unnecessary_attribute.sqlV11__rename_grading_question_criterion.sqlV120__adding_reviewer_and_cosupervisor_set_to_project.sqlV121__language_to_enums.sqlV122__renamed_free_text_answer_to_motivation.sqlV123__bye_peer_ratings.sqlV124__remove_peer_rating_setting.sqlV125__remove_peer_priority.sqlV126__removed_thesis_file_from_file_description.sqlV127__add_source_to_file_description.sqlV128__feedback_to_longtext.sqlV129__renaming.sqlV12__finished_boolean.sqlV130__checklist_notification_urls.sqlV131__forum_notification_urls.sqlV132__file_attachment_to_reports.sqlV133__research_plan.sqlV134__externallink.sqlV135__removed_old_thesis_link.sqlV136__removed_unused_general_system_settings.sqlV137__show_single_sign_on_settings.sqlV138__increasing_length_of_thesis_summary.sqlV139__department_service.sqlV13__remove_useless_columns.sqlV140__transaction.sqlV141__roughdraft.sqlV142__final_seminar_approval.sqlV143__thread_refactoring.sqlV144__drop_thread_columns.sqlV145__changed_reference_in_forum_posts.sqlV146__rough_draft_approval.sqlV147__approval_refactoring.sqlV148__removed_year_from_annual_review.sqlV149__remove_draft_from_project.sqlV14__final_thesis_date_approved.sqlV150__added_events_when_reviewer_steps_are_approved.sqlV151__added_external_resources.sqlV152__extended_event_column_to_accomodate_long_enums.sqlV153__removed_separate_realm_column_from_username.sqlV154__added_evaluation_url.sqlV156__adding_footer_link.sqlV157__made_reason_in_decision_longtext.sqlV158__creating_reviewer_deadline_settings.sqlV159__modifying_approvals.sqlV15__final_thesis_date_rejected.sqlV160__adding_footer_address.sqlV161__added_requested_and_decision_date_to_decision.sqlV162__change_employee_to_supervisor.sqlV163__change_student_to_author.sqlV164__added_opposition_priority_days.sqlV165_1__migrated_language_enums_to_database.sqlV165_2__migrated_final_seminar_language.sqlV165_3__migrated_idea_to_language_entity.sqlV165_4__migrated_user_to_language_entity.sqlV166__create_group.sqlV167__group_fixes.sqlV168__removing_remote_export_setting.sqlV169__group_forum_entities.sqlV16__grading_report_export.sql

@ -234,14 +234,8 @@ public class DataInitializer implements Lifecycle {
}
private void createGradingCriterionTemplateIfNotDone() {
save(getBachelorTemplate());
save(getBachelorTemplate());
save(getBachelorTemplate());
save(getMasterTemplate());
save(getMasterTemplate());
save(getMasterTemplate());
save(getMagisterTemplate());
save(getMagisterTemplate());
save(getMagisterTemplate());
}

@ -1 +0,0 @@
ALTER TABLE `checklist` ADD COLUMN `description` LONGTEXT DEFAULT NULL;

@ -1 +0,0 @@
ALTER TABLE `file_description` MODIFY COLUMN `type` VARCHAR(255);

@ -1 +0,0 @@
insert into Event values ('FinalSeminarCreated','Final seminar created');

@ -1,2 +0,0 @@
ALTER TABLE `file_description` ADD CONSTRAINT `file_description_user` FOREIGN KEY (`userId`) REFERENCES `user` (`id`);
ALTER TABLE `file_description` DROP COLUMN `data`;

@ -1 +0,0 @@
ALTER TABLE `file_description` DROP COLUMN `targetLastModified`;

@ -1,39 +0,0 @@
create temporary table `remove_checklists` (id bigint);
insert into remove_checklists
select checklist_id from checklist_checklist_category
where categories_id = (select id from checklist_category where categoryName = 'Supervisor')
and checklist_id not in (select checklist_id from checklist_checklist_category
where categories_id not in (select id from checklist_category where categoryName = 'Supervisor'));
create temporary table `remove_answers` (id bigint);
insert into remove_answers select answers_id from checklist_question_checklist_answer where checklist_question_id in
(select questions_id from checklist_checklist_question where checklist_id in (select id from remove_checklists));
delete from checklist_question_checklist_answer where checklist_question_id in
(select questions_id from checklist_checklist_question where checklist_id in
(select id from remove_checklists));
delete from checklist_answer where id in
(select id from remove_answers);
create temporary table `remove_questions` (id bigint);
insert into remove_questions select questions_id from checklist_checklist_question where checklist_id in
(select id from remove_checklists);
delete from checklist_checklist_question where checklist_id in (select id from remove_checklists);
delete from checklist_question where id in (select id from remove_questions);
delete from checklist_checklist_category where checklist_id in (select id from remove_checklists);
delete from Checklist_userLastOpenDate where CheckList_id in (select id from remove_checklists);
delete from project_checklist where checkLists_id in (select id from remove_checklists);
UPDATE project_schedule_event
SET checkList_id = NULL
WHERE checkList_id in (select id from remove_checklists);
delete from checklist where id in (select id from remove_checklists);

@ -1,19 +0,0 @@
create temporary table `remove_checklist_templates` (id bigint);
insert into remove_checklist_templates
select checklist_template_id from checklist_template_checklist_category
where categories_id = (select id from checklist_category where categoryName = 'Supervisor')
and checklist_template_id not in (select checklist_id from checklist_checklist_category
where categories_id not in (select id from checklist_category where categoryName = 'Supervisor'));
delete from ChecklistTemplate_questions where CheckListTemplate_id in (select id from remove_checklist_templates);
delete from checklist_template_checklist_category where checklist_template_id in (select id from remove_checklist_templates);
update peer_request set checkListTemplate_id = NULL where checkListTemplate_id in (select id from remove_checklist_templates);
update project_event_template set checkListTemplate_id = NULL where checkListTemplate_id in (select id from remove_checklist_templates);
delete from checklist_template_ProjectType where checklist_template_id in (select id from remove_checklist_templates);
delete from checklist_template where id in (select id from remove_checklist_templates);
delete from checklist_category where categoryName = 'Supervisor';

@ -1 +0,0 @@
ALTER TABLE `file_description` ADD COLUMN `deletable` BOOLEAN NOT NULL DEFAULT FALSE;

@ -1,43 +0,0 @@
CREATE TABLE IF NOT EXISTS `AnnualReview` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`year` int(4) NOT NULL,
`annualReview_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_1lixh18i7nf77ewo7kbcpp0s2` (`annualReview_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
ALTER TABLE `AnnualReview`
ADD CONSTRAINT `FK_1lixh18i7nf77ewo7kbcpp0s2` FOREIGN KEY (`annualReview_id`) REFERENCES `file_description` (`id`);
CREATE TABLE IF NOT EXISTS `PhD` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`basicContract_id` bigint(20) DEFAULT NULL,
`project_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_ulti91hg79n6uve40ypk4ep8` (`project_id`),
KEY `FK_gjws84yb3jwcjtsl566p7elwt` (`basicContract_id`),
KEY `FK_ulti91hg79n6uve40ypk4ep8` (`project_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
ALTER TABLE `PhD`
ADD CONSTRAINT `FK_ulti91hg79n6uve40ypk4ep8` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`),
ADD CONSTRAINT `FK_gjws84yb3jwcjtsl566p7elwt` FOREIGN KEY (`basicContract_id`) REFERENCES `file_description` (`id`);
CREATE TABLE IF NOT EXISTS `PhD_AnnualReview` (
`PhD_id` bigint(20) NOT NULL,
`annualReviews_id` bigint(20) NOT NULL,
PRIMARY KEY (`PhD_id`,`annualReviews_id`),
UNIQUE KEY `UK_s7qfudoo5kkayljbmyyssfywi` (`annualReviews_id`),
KEY `FK_s7qfudoo5kkayljbmyyssfywi` (`annualReviews_id`),
KEY `FK_8gpidcs94cr95v2mgk5be6x8b` (`PhD_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `PhD_AnnualReview`
ADD CONSTRAINT `FK_8gpidcs94cr95v2mgk5be6x8b` FOREIGN KEY (`PhD_id`) REFERENCES `PhD` (`id`),
ADD CONSTRAINT `FK_s7qfudoo5kkayljbmyyssfywi` FOREIGN KEY (`annualReviews_id`) REFERENCES `AnnualReview` (`id`);

@ -1,4 +0,0 @@
ALTER TABLE `AnnualReview` CONVERT TO CHARACTER SET utf8;
ALTER TABLE `PhD` CONVERT TO CHARACTER SET utf8;
ALTER TABLE `PhD_AnnualReview` CONVERT TO CHARACTER SET utf8;
ALTER TABLE `ApplicationPeriodProjectType` CONVERT TO CHARACTER SET utf8;

@ -1,3 +0,0 @@
ALTER TABLE `grading_report_template` MODIFY COLUMN `description` VARCHAR(2000);
ALTER TABLE `grading_question` MODIFY COLUMN `description` VARCHAR(2000);
ALTER TABLE `grading_answer` ADD COLUMN `feedback` VARCHAR(2000);

@ -1,2 +0,0 @@
update project set dateCreated = daisyStartDate where dateCreated is null;
alter table project drop column daisyStartDate;

@ -1,2 +0,0 @@
ALTER TABLE `NotificationData` DROP FOREIGN KEY `FK2DCAC3554D07E0A9`;
ALTER TABLE `NotificationData` ADD CONSTRAINT `FK2DCAC3554D07E0A9` FOREIGN KEY (`seminar_id`) REFERENCES `final_seminar` (`id`) ON DELETE CASCADE;

@ -1,6 +0,0 @@
CREATE TABLE `project_type_modules` (
`ProjectType_id` bigint(20) NOT NULL,
`modules` varchar(255) DEFAULT NULL,
KEY `FK_4attsf1e22qpveesgl6o9b7lg` (`ProjectType_id`),
CONSTRAINT `FK_4attsf1e22qpveesgl6o9b7lg` FOREIGN KEY (`ProjectType_id`) REFERENCES `ProjectType` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -1,5 +0,0 @@
RENAME TABLE `PhD` TO `StudyPlan`;
ALTER TABLE `AnnualReview` ADD COLUMN `studyPlan_id` BIGINT(20);
ALTER TABLE `AnnualReview` ADD CONSTRAINT `FK_annual_review_study_plan` FOREIGN KEY (`studyPlan_id`) REFERENCES `StudyPlan` (`id`);
UPDATE `AnnualReview` SET `studyPlan_id` = (SELECT `PhD_id` FROM `PhD_AnnualReview` WHERE `annualReviews_id` = `AnnualReview`.`id`);
DROP TABLE `PhD_AnnualReview`;

@ -1,3 +0,0 @@
ALTER TABLE `projectPartner` DROP FOREIGN KEY `FK_projectPartner_projectType`;
ALTER TABLE `projectPartner` DROP KEY `FK_projectPartner_projectType`;
ALTER TABLE `projectPartner` DROP `projectType_id`;

@ -1,5 +0,0 @@
ALTER TABLE `final_seminar_active_participation` ADD COLUMN `user_id` BIGINT(20) NOT NULL;
UPDATE `final_seminar_active_participation` SET `user_id` = (SELECT `user_id` FROM `role` WHERE `role`.`id` = `student_id`);
ALTER TABLE `final_seminar_active_participation` ADD CONSTRAINT `final_seminar_active_participation_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `final_seminar_active_participation` DROP FOREIGN KEY `FK_active_participation_student_id`;
ALTER TABLE `final_seminar_active_participation` DROP COLUMN `student_id`;

@ -1,5 +0,0 @@
ALTER TABLE `milestone` ADD COLUMN `user_id` BIGINT(20) DEFAULT NULL;
UPDATE `milestone` SET `user_id` = (SELECT `user_id` FROM `role` WHERE `id` = `student_id` AND `student_id` IS NOT NULL);
ALTER TABLE `milestone` ADD CONSTRAINT `milestone_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `milestone` DROP FOREIGN KEY `FKC08419709BD14DD5`;
ALTER TABLE `milestone` DROP COLUMN `student_id`;

@ -1,5 +0,0 @@
ALTER TABLE `project` ADD COLUMN `supervisor_id` BIGINT(20) DEFAULT NULL;
UPDATE `project` SET `supervisor_id` = (SELECT `user_id` FROM `role` WHERE `id` = `headSupervisor_id`);
ALTER TABLE `project` ADD CONSTRAINT `project_supervisor_id` FOREIGN KEY (`supervisor_id`) REFERENCES `user` (`id`);
ALTER TABLE `project` DROP FOREIGN KEY `FK_6k74jgcmji5vo3lheg4npoaql`;
ALTER TABLE `project` DROP COLUMN `headSupervisor_id`;

@ -1,5 +0,0 @@
ALTER TABLE `project_follower` ADD COLUMN `user_id` BIGINT(20) NOT NULL;
UPDATE `project_follower` SET `user_id` = (SELECT `user_id` FROM `role` WHERE `id` = `follower_id`);
ALTER TABLE `project_follower` ADD CONSTRAINT `project_follower_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `project_follower` DROP FOREIGN KEY `FK_h49g8tc2d8q69y3i66nj404h7`;
ALTER TABLE `project_follower` DROP COLUMN `follower_id`;

@ -1,6 +0,0 @@
ALTER TABLE `peer_review` DROP FOREIGN KEY `FK_9xy59w1sbydtuplendcthlhu5`;
ALTER TABLE `peer_review` CHANGE COLUMN `reviewer_id` `foo` BIGINT(20) NOT NULL;
ALTER TABLE `peer_review` ADD COLUMN `reviewer_id` BIGINT(20) NOT NULL;
UPDATE `peer_review` SET `reviewer_id` = (SELECT `user_id` FROM `role` WHERE `id` = `foo`);
ALTER TABLE `peer_review` ADD CONSTRAINT `peer_review_reviewer_id` FOREIGN KEY (`reviewer_id`) REFERENCES `user` (`id`);
ALTER TABLE `peer_review` DROP COLUMN `foo`;

@ -1,6 +0,0 @@
ALTER TABLE `peer_request` DROP FOREIGN KEY `FK_ihqq9n3eb7ycvd5ggjxx5wn38`;
ALTER TABLE `peer_request` CHANGE COLUMN `requester_id` `foo` BIGINT(20) NOT NULL;
ALTER TABLE `peer_request` ADD COLUMN `requester_id` BIGINT(20) NOT NULL;
UPDATE `peer_request` SET `requester_id` = (SELECT `user_id` FROM `role` WHERE `id` = `foo`);
ALTER TABLE `peer_request` ADD CONSTRAINT `peer_request_reviewer_id` FOREIGN KEY (`requester_id`) REFERENCES `user` (`id`);
ALTER TABLE `peer_request` DROP COLUMN `foo`;

@ -1,7 +0,0 @@
ALTER TABLE `applicationperiodexemption` ADD COLUMN `user_id` BIGINT(20) NOT NULL;
UPDATE `applicationperiodexemption` SET `user_id` = (SELECT `user_id` FROM `role` WHERE `id` = `studentId`);
ALTER TABLE `applicationperiodexemption` ADD CONSTRAINT `applicationperiodexemption_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `applicationperiodexemption` DROP FOREIGN KEY `FKCB7E71913353DC5C`;
ALTER TABLE `applicationperiodexemption` DROP PRIMARY KEY;
ALTER TABLE `applicationperiodexemption` ADD PRIMARY KEY (`user_id`, `applicationPeriodId`);
ALTER TABLE `applicationperiodexemption` DROP COLUMN `studentId`;

@ -1,5 +0,0 @@
ALTER TABLE `idea_student` ADD COLUMN `user_id` BIGINT(20) NOT NULL;
UPDATE `idea_student` SET `user_id` = (SELECT `user_id` FROM `role` WHERE `id` = `role_id`);
ALTER TABLE `idea_student` ADD CONSTRAINT `idea_student_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `idea_student` DROP FOREIGN KEY `FK9458BA932B6C61BA`;
ALTER TABLE `idea_student` DROP COLUMN `role_id`;

@ -1,6 +0,0 @@
ALTER TABLE `idea_match` DROP FOREIGN KEY `FK87EA481DBCA56165`;
ALTER TABLE `idea_match` CHANGE COLUMN `supervisor_id` `foo` BIGINT(20) DEFAULT NULL;
ALTER TABLE `idea_match` ADD COLUMN `supervisor_id` BIGINT(20) DEFAULT NULL;
UPDATE `idea_match` SET `supervisor_id` = (SELECT `user_id` FROM `role` WHERE `id` = `foo`);
ALTER TABLE `idea_match` ADD CONSTRAINT `idea_match_supervisor_id` FOREIGN KEY (`supervisor_id`) REFERENCES `user` (`id`);
ALTER TABLE `idea_match` DROP COLUMN `foo`;

@ -1,7 +0,0 @@
ALTER TABLE `target` ADD COLUMN `user_id` BIGINT(20) NOT NULL;
UPDATE `target` SET `user_id` = (SELECT `user_id` FROM `role` WHERE `id` = `employeeId`);
ALTER TABLE `target` ADD CONSTRAINT `target_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `target` DROP FOREIGN KEY `FKCB7E71913353DC5Cb`;
ALTER TABLE `target` DROP PRIMARY KEY;
ALTER TABLE `target` ADD PRIMARY KEY (`user_id`, `applicationPeriodId`, `projectTypeId`);
ALTER TABLE `target` DROP COLUMN `employeeId`;

@ -1,13 +0,0 @@
CREATE TABLE `user_program` (
`user_id` BIGINT(20) NOT NULL,
`program_id` BIGINT(20) NOT NULL,
PRIMARY KEY (`user_id`, `program_id`),
CONSTRAINT `user_program_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
CONSTRAINT `user_program_program_id` FOREIGN KEY (`program_id`) REFERENCES `Program` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `user_program` (`user_id`, `program_id`)
SELECT `user`.`id`, `role_Program`.`programs_id`
FROM `role_Program`
INNER JOIN `role` ON `role`.`id` = `role_Program`.`role_id`
INNER JOIN `user` ON `user`.`id` = `role`.`user_id`;

@ -1,6 +0,0 @@
ALTER TABLE `final_seminar` DROP FOREIGN KEY `FK49900D2873048D7F`;
ALTER TABLE `final_seminar` CHANGE COLUMN `examiner_id` `foo` BIGINT(20) DEFAULT NULL;
ALTER TABLE `final_seminar` ADD COLUMN `examiner_id` BIGINT(20) DEFAULT NULL;
UPDATE `final_seminar` SET `examiner_id` = (SELECT `user_id` FROM `role` WHERE `id` = `foo`);
ALTER TABLE `final_seminar` ADD CONSTRAINT `final_seminar_examiner_id` FOREIGN KEY (`examiner_id`) REFERENCES `user` (`id`);
ALTER TABLE `final_seminar` DROP COLUMN `foo`;

@ -1,6 +0,0 @@
DROP TABLE `role_Program`;
DROP TABLE `Employee_Language`;
DROP TABLE `employee_researcharea`;
DROP TABLE `SupervisorNotificationSettings`;
DROP TABLE `project_student`;
DROP TABLE `role`;

@ -1,13 +0,0 @@
CREATE TABLE `user_language` (
`user_id` BIGINT(20) NOT NULL,
`language_id` BIGINT(20) NOT NULL,
PRIMARY KEY (`user_id`, `language_id`),
CONSTRAINT `user_language_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
CONSTRAINT `user_language_language_id` FOREIGN KEY (`language_id`) REFERENCES `Language` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `user_language` (`user_id`, `language_id`)
SELECT `user`.`id`, `Employee_Language`.`languages_id`
FROM `Employee_Language`
INNER JOIN `role` ON `role`.`id` = `Employee_Language`.`role_id`
INNER JOIN `user` ON `user`.`id` = `role`.`user_id`;

@ -1,13 +0,0 @@
CREATE TABLE `user_research_area` (
`user_id` BIGINT(20) NOT NULL,
`research_area_id` BIGINT(20) NOT NULL,
PRIMARY KEY (`user_id`, `research_area_id`),
CONSTRAINT `user_research_area_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
CONSTRAINT `user_research_area_research_area_id` FOREIGN KEY (`research_area_id`) REFERENCES `researcharea` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `user_research_area` (`user_id`, `research_area_id`)
SELECT `user`.`id`, `employee_researcharea`.`researchAreas_id`
FROM `employee_researcharea`
INNER JOIN `role` ON `role`.`id` = `employee_researcharea`.`role_id`
INNER JOIN `user` ON `user`.`id` = `role`.`user_id`;

@ -1,3 +0,0 @@
ALTER TABLE `user` ADD COLUMN `unit_id` BIGINT(20) DEFAULT NULL;
ALTER TABLE `user` ADD CONSTRAINT `user_unit_id` FOREIGN KEY (`unit_id`) REFERENCES `unit` (`id`);
UPDATE `user` SET `unit_id` = (SELECT `unit_id` FROM `role` WHERE `user_id` = `user`.`id` AND `unit_id` IS NOT NULL);

@ -1,11 +0,0 @@
CREATE TABLE `user_role` (
`user_id` BIGINT(20) NOT NULL,
`role` VARCHAR(255) NOT NULL,
PRIMARY KEY (`user_id`, `role`),
CONSTRAINT `user_role_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `user_role` (`user_id`, `role`)
SELECT `user_id`, UPPER(`rolename`)
FROM `role`;

@ -1,12 +0,0 @@
CREATE TABLE `project_user` (
`user_id` BIGINT(20) NOT NULL,
`project_id` BIGINT(20) NOT NULL,
PRIMARY KEY (`user_id`, `project_id`),
CONSTRAINT `project_user_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
CONSTRAINT `project_user_project_id` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `project_user` (`user_id`, `project_id`)
SELECT `role`.`user_id`, `project_student`.`project_id`
FROM `project_student`
INNER JOIN `role` ON `role`.`id` = `project_student`.`projectParticipants_id`;

@ -1,5 +0,0 @@
ALTER TABLE `SupervisorGradingReport` ADD COLUMN `user_id` BIGINT(20) NOT NULL;
UPDATE `SupervisorGradingReport` SET `user_id` = (SELECT `user_id` FROM `role` WHERE `role`.`id` = `student_id`);
ALTER TABLE `SupervisorGradingReport` ADD CONSTRAINT `supervisor_grading_report_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `SupervisorGradingReport` DROP FOREIGN KEY `FK_2vi1wacprhrqlc8agx08btx34`;
ALTER TABLE `SupervisorGradingReport` DROP COLUMN `student_id`;

@ -1,5 +0,0 @@
ALTER TABLE `final_seminar_respondent` ADD COLUMN `user_id` BIGINT(20) NOT NULL;
UPDATE `final_seminar_respondent` SET `user_id` = (SELECT `user_id` FROM `role` WHERE `role`.`id` = `student_id`);
ALTER TABLE `final_seminar_respondent` ADD CONSTRAINT `final_seminar_respondent_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `final_seminar_respondent` DROP FOREIGN KEY `FK_student_respondent_id`;
ALTER TABLE `final_seminar_respondent` DROP COLUMN `student_id`;

@ -1,5 +0,0 @@
ALTER TABLE `final_seminar_opposition` ADD COLUMN `user_id` BIGINT(20) NOT NULL;
UPDATE `final_seminar_opposition` SET `user_id` = (SELECT `user_id` FROM `role` WHERE `role`.`id` = `student_id`);
ALTER TABLE `final_seminar_opposition` ADD CONSTRAINT `final_seminar_opposition_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `final_seminar_opposition` DROP FOREIGN KEY `FK_opposition_student_id`;
ALTER TABLE `final_seminar_opposition` DROP COLUMN `student_id`;

@ -1,6 +0,0 @@
ALTER TABLE `schedule_template` DROP FOREIGN KEY `FK_schedule_template_projectType`;
ALTER TABLE `schedule_template` DROP COLUMN `projectType_id`;
ALTER TABLE `project_event_template` DROP FOREIGN KEY `FK_p8buy8evr4g6u8nkbml0mdf1v`;
ALTER TABLE `project_event_template` DROP COLUMN `templateCreator_id`;
ALTER TABLE `project_event_template` DROP COLUMN `estimatedTimeConsumption`;

@ -1,2 +0,0 @@
ALTER TABLE `checklist_template`
DROP `numberOfQuestions`;

@ -1 +0,0 @@
ALTER TABLE `grading_report_template` ADD COLUMN `credits` INT(11);

@ -1,3 +0,0 @@
ALTER TABLE `project_schedule_event` DROP FOREIGN KEY `creator_id_index`;
ALTER TABLE `project_schedule_event` DROP KEY `creator_id_index`;
ALTER TABLE `project_schedule_event` DROP `creator_id`;

@ -1 +0,0 @@
RENAME TABLE `grading_question` TO `grading_criterion`;

@ -1,37 +0,0 @@
CREATE TABLE IF NOT EXISTS `project_reviewer` (
`project_id` bigint(20) NOT NULL,
`user_id` bigint(20) NOT NULL,
PRIMARY KEY (`project_id`,`user_id`),
KEY `FK_g7yryw3e0dtmuuvgw5qjhphjm` (`user_id`),
KEY `FK_6aik0jd18kv3383fbt09xd0pi` (`project_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `project_reviewer`
ADD CONSTRAINT `FK_6aik0jd18kv3383fbt09xd0pi` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`),
ADD CONSTRAINT `FK_g7yryw3e0dtmuuvgw5qjhphjm` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
INSERT INTO `project_reviewer` (`user_id`, `project_id`) (
SELECT `user_id` , `project_id`
FROM `project_follower`
WHERE `projectRole` = 'REVIEWER'
);
CREATE TABLE IF NOT EXISTS `project_cosupervisor` (
`user_id` bigint(20) NOT NULL,
`project_id` bigint(20) NOT NULL,
PRIMARY KEY (`user_id`,`project_id`),
KEY `FK_18x2poxkt8s2bw9kpr7vbmd5j` (`user_id`),
KEY `FK_fj57t069dymdrnnhdxcnfvvnn` (`project_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `project_cosupervisor`
ADD CONSTRAINT `FK_fj57t069dymdrnnhdxcnfvvnn` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`),
ADD CONSTRAINT `FK_18x2poxkt8s2bw9kpr7vbmd5j` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
INSERT INTO `project_cosupervisor` (`user_id`, `project_id`) (
SELECT DISTINCT `user_id` , `project_id`
FROM `project_follower`
WHERE `projectRole` = 'CO_SUPERVISOR'
);
DROP TABLE `project_follower`;

@ -1,16 +0,0 @@
CREATE TABLE `user_languages` (
`user_id` bigint(20) NOT NULL,
`languages` varchar(255) DEFAULT NULL,
KEY `user_languages_user_id` (`user_id`),
CONSTRAINT `user_languages_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `user_languages` (`user_id`, `languages`) SELECT `user_id`, UPPER(`Language`.`name`)
FROM `user_language` INNER JOIN `Language` ON `Language`.`id` = `user_language`.`language_id`;
DROP TABLE `user_language`;
ALTER TABLE `idea` DROP FOREIGN KEY `FK6E0518973BE9881F`;
ALTER TABLE `idea` ADD COLUMN `language` VARCHAR(255) DEFAULT NULL;
UPDATE `idea` SET `language` = (SELECT UPPER(`name`) FROM `Language` where `id` = language_id);
ALTER TABLE `idea` DROP COLUMN `language_id`;

@ -1 +0,0 @@
ALTER TABLE `answer` CHANGE COLUMN `freeTextAnswer` `motivation` LONGTEXT;

@ -1 +0,0 @@
DROP TABLE review_rating;

@ -1 +0,0 @@
ALTER TABLE `general_system_settings` DROP COLUMN `peerRatingsEnabled`;

@ -1 +0,0 @@
ALTER TABLE `project_type_settings` DROP COLUMN `numDaysBeforePeerRequestPriority`;

@ -1 +0,0 @@
ALTER TABLE `file_description` DROP COLUMN `isThesisFile`;

@ -1 +0,0 @@
ALTER TABLE `file_description` ADD COLUMN `fileSource` VARCHAR(255);

@ -1,2 +0,0 @@
ALTER TABLE `criterion` MODIFY COLUMN `feedback` LONGTEXT DEFAULT NULL;
ALTER TABLE `GradingCriterion` MODIFY COLUMN `feedback` LONGTEXT DEFAULT NULL;

@ -1,27 +0,0 @@
RENAME TABLE `schedule_template` TO `ActivityPlanTemplate`;
RENAME TABLE `project_event_template` TO `ActivityTemplate`;
ALTER TABLE `ActivityTemplate` DROP FOREIGN KEY `FK_ca5bhq3i6p2g292fo5l4fqtf`;
ALTER TABLE `ActivityTemplate` DROP KEY `FKD4434665C5FC509F`;
ALTER TABLE `ActivityTemplate` CHANGE `scheduleTemplate_id` `activityPlanTemplate_id` bigint(20) DEFAULT NULL;
ALTER TABLE `ActivityTemplate` ADD KEY `FKD4434665C5FC509F` (`activityPlanTemplate_id`);
ALTER TABLE `ActivityTemplate` ADD CONSTRAINT `FK_ca5bhq3i6p2g292fo5l4fqtf` FOREIGN KEY (`activityPlanTemplate_id`) REFERENCES `ActivityPlanTemplate` (`id`);
ALTER TABLE `ApplicationPeriodProjectType` DROP FOREIGN KEY `FK_3ku67jvegs1xxh8ykk023i7sb`;
ALTER TABLE `ApplicationPeriodProjectType` DROP KEY `FK_3ku67jvegs1xxh8ykk023i7sb`;
ALTER TABLE `ApplicationPeriodProjectType` CHANGE `scheduleTemplate_id` `activityPlanTemplate_id` bigint(20) DEFAULT NULL;
ALTER TABLE `ApplicationPeriodProjectType` ADD KEY `FK_3ku67jvegs1xxh8ykk023i7sb` (`activityPlanTemplate_id`);
ALTER TABLE `ApplicationPeriodProjectType` ADD CONSTRAINT `FK_3ku67jvegs1xxh8ykk023i7sb` FOREIGN KEY (`activityPlanTemplate_id`) REFERENCES `ActivityPlanTemplate` (`id`);
ALTER TABLE `ActivityPlanTemplate` CHANGE `templateDescription` `description` longtext;
ALTER TABLE `ActivityPlanTemplate` CHANGE `templateName` `title` varchar(255) NOT NULL;
RENAME TABLE `project_schedule` TO `ActivityPlan`;
RENAME TABLE `project_schedule_event` TO `Activity`;
ALTER TABLE `Activity` DROP FOREIGN KEY `projectSchedule_id_index`;
ALTER TABLE `Activity` DROP KEY `projectSchedule_id_index`;
ALTER TABLE `Activity` CHANGE `projectSchedule_id` `activityTemplate_id` bigint(20) NOT NULL;
ALTER TABLE `Activity` ADD KEY `activityTemplate_id_index` (`activityTemplate_id`);
ALTER TABLE `Activity` ADD CONSTRAINT `activityTemplate_id_index` FOREIGN KEY (`activityTemplate_id`) REFERENCES `ActivityPlan` (`id`);
ALTER TABLE `Activity` CHANGE `name` `title` varchar(500) NOT NULL;

@ -1 +0,0 @@
ALTER TABLE `grading_report` ADD COLUMN `finished` BOOLEAN DEFAULT FALSE NOT NULL;

@ -1,3 +0,0 @@
UPDATE Notification
SET absoluteURL = REPLACE(absoluteURL, '&checklist=', '&clid=')
WHERE absoluteURL LIKE '%&checklist=%';

@ -1,7 +0,0 @@
UPDATE Notification
SET absoluteURL = REPLACE(absoluteURL, '&tid=', '&ftid=')
WHERE absoluteURL LIKE '%&tid=%';
UPDATE Notification
SET absoluteURL = REPLACE(absoluteURL, '&postID=', '&fpid=')
WHERE absoluteURL LIKE '%&postID=%';

@ -1,5 +0,0 @@
ALTER TABLE `opposition_report` ADD `attachment_id` bigint(20) DEFAULT NULL;
ALTER TABLE `opposition_report` ADD CONSTRAINT `opposition_report_attachment_id` FOREIGN KEY (`attachment_id`) REFERENCES `file_description` (`id`);
ALTER TABLE `preliminary_grading_report` ADD `attachment_id` bigint(20) DEFAULT NULL;
ALTER TABLE `preliminary_grading_report` ADD CONSTRAINT `preliminary_grading_report_attachment_id` FOREIGN KEY (`attachment_id`) REFERENCES `file_description` (`id`);

@ -1,13 +0,0 @@
CREATE TABLE `research_plan` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`project_id` bigint(20) NOT NULL,
`file_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `research_plan_project` (`project_id`),
KEY `research_plan_file` (`file_id`),
CONSTRAINT `research_plan_project` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`),
CONSTRAINT `research_plan_file` FOREIGN KEY (`file_id`) REFERENCES `file_description` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -1,22 +0,0 @@
CREATE TABLE IF NOT EXISTS `externallink` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`url` varchar(255) NOT NULL,
`project_id` bigint(20) NOT NULL,
`user_id` bigint(20) NOT NULL,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_PROJECT` (`project_id`),
KEY `FK_USER` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
ALTER TABLE `externallink`
ADD CONSTRAINT `FK_USER` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
ADD CONSTRAINT `FK_PROJECT` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`);
INSERT INTO `externallink` (`dateCreated`, `lastModified`, `version`, `url`, `project_id`, `user_id`)
SELECT `thesislink`.`dateCreated`, `thesislink`.`lastModified`, `thesislink`.`version`, `thesislink`.`URL`, `thesislink`.`project_id`, `project`.`supervisor_id`
FROM `thesislink`, `project`
WHERE `thesislink`.`project_id` = `project`.`id`;

@ -1,2 +0,0 @@
ALTER TABLE `general_system_settings` DROP COLUMN `bachelorCountDate`;
ALTER TABLE `general_system_settings` DROP COLUMN `masterCountDate`;

@ -1 +0,0 @@
ALTER TABLE `general_system_settings` ADD COLUMN `showSingleSignOn` BOOLEAN DEFAULT TRUE NOT NULL;

@ -1 +0,0 @@
ALTER TABLE `opposition_report` CHANGE `thesisSummary` `thesisSummary` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;

@ -1,14 +0,0 @@
CREATE TABLE `department_service` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` DATETIME NOT NULL,
`lastModified` DATETIME NOT NULL,
`version` int(11) NOT NULL,
`user_id` bigint(20) NOT NULL,
`dateStarted` DATETIME NOT NULL,
`dateEnded` DATETIME NOT NULL,
`hours` INT NOT NULL,
`description` LONGTEXT DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `department_service_user` (`user_id`),
CONSTRAINT `department_service_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -1,5 +0,0 @@
ALTER TABLE `user_settings`
DROP `apiKey`,
DROP `available`,
DROP `iPhoneId`,
DROP `statusMessage`;

@ -1,17 +0,0 @@
CREATE TABLE IF NOT EXISTS `transaction` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`project_id` bigint(20) NOT NULL,
`user_id` bigint(20) NOT NULL,
`amount` int(11) NOT NULL,
`comment` longtext,
PRIMARY KEY (`id`),
KEY `FK_transaction_project` (`project_id`),
KEY `FK_transaction_user` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
ALTER TABLE `transaction`
ADD CONSTRAINT `FK_transaction_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
ADD CONSTRAINT `FK_transaction_project` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`);

@ -1,3 +0,0 @@
ALTER TABLE `project` ADD `draft_id` bigint(20) DEFAULT NULL;
ALTER TABLE `project` ADD KEY `FK_draft` (`draft_id`);
ALTER TABLE `project` ADD CONSTRAINT `FK_draft` FOREIGN KEY (`draft_id`) REFERENCES `file_description` (`id`);

@ -1,32 +0,0 @@
CREATE TABLE `Decision` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`reason` varchar(255) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
`attachment_id` bigint(20) DEFAULT NULL,
`thesis_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_d3pbhn9dtb5oqmjhpgk5cs4t1` (`attachment_id`),
KEY `FK_s9cnrqblgomd6mhoaet3lgg1b` (`thesis_id`),
CONSTRAINT `FK_s9cnrqblgomd6mhoaet3lgg1b` FOREIGN KEY (`thesis_id`) REFERENCES `file_description` (`id`),
CONSTRAINT `FK_d3pbhn9dtb5oqmjhpgk5cs4t1` FOREIGN KEY (`attachment_id`) REFERENCES `file_description` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `FinalSeminarApproval` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`project_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_9lr1dn8boyfc5a0477ld4q8rw` (`project_id`),
CONSTRAINT `FK_9lr1dn8boyfc5a0477ld4q8rw` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `FinalSeminarApproval_Decision` (
`FinalSeminarApproval_id` bigint(20) NOT NULL,
`decisions_id` bigint(20) NOT NULL,
`decisions_ORDER` int(11) NOT NULL,
PRIMARY KEY (`FinalSeminarApproval_id`,`decisions_ORDER`),
UNIQUE KEY `UK_r1ba76xigvossvqj1vrkxy2cc` (`decisions_id`),
KEY `FK_r1ba76xigvossvqj1vrkxy2cc` (`decisions_id`),
KEY `FK_7g4wtjpvw81tv6hna7vwvu05f` (`FinalSeminarApproval_id`),
CONSTRAINT `FK_7g4wtjpvw81tv6hna7vwvu05f` FOREIGN KEY (`FinalSeminarApproval_id`) REFERENCES `FinalSeminarApproval` (`id`),
CONSTRAINT `FK_r1ba76xigvossvqj1vrkxy2cc` FOREIGN KEY (`decisions_id`) REFERENCES `Decision` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -1,22 +0,0 @@
CREATE TABLE `thread` (
`id` BIGINT(20) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`deleted` tinyint(1) NOT NULL,
`project` bigint(20) NOT NULL,
`subject` varchar(1000) NOT NULL,
KEY `thread_project` (`project`)
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
ALTER TABLE `thread` ADD CONSTRAINT `thread_project` FOREIGN KEY (`project`) REFERENCES `project` (`id`);
CREATE TABLE `reviewer_thread` (
`id` BIGINT(20) NOT NULL PRIMARY KEY AUTO_INCREMENT
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
ALTER TABLE `reviewer_thread` ADD CONSTRAINT `reviewer_thread_thread` FOREIGN KEY (`id`) REFERENCES `thread` (`id`);
INSERT INTO `thread` SELECT `id`, `dateCreated`, `lastModified`, `version`, `deleted`, `project`, `subject` FROM `forum_threads`;
ALTER TABLE `forum_threads` ADD CONSTRAINT `forum_threads_thread` FOREIGN KEY (`id`) REFERENCES `thread` (`id`);

@ -1,9 +0,0 @@
ALTER TABLE `forum_threads` DROP COLUMN `dateCreated`;
ALTER TABLE `forum_threads` DROP COLUMN `lastModified`;
ALTER TABLE `forum_threads` DROP COLUMN `version`;
ALTER TABLE `forum_threads` DROP COLUMN `deleted`;
ALTER TABLE `forum_threads` DROP FOREIGN KEY `FKAF97368B247CE02D`;
ALTER TABLE `forum_threads` DROP COLUMN `project`;
ALTER TABLE `forum_threads` DROP COLUMN `subject`;

@ -1,2 +0,0 @@
ALTER TABLE `forum_posts` DROP FOREIGN KEY `FKEDDC4F355E9380A1`;
ALTER TABLE `forum_posts` ADD CONSTRAINT `forum_posts_thread` FOREIGN KEY (`thread`) REFERENCES `thread` (`id`);

@ -1,19 +0,0 @@
CREATE TABLE `RoughDraftApproval` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`project_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `rough_draft_approval_project` (`project_id`),
CONSTRAINT `rough_draft_approval_project` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `RoughDraftApproval_Decision` (
`RoughDraftApproval_id` bigint(20) NOT NULL,
`decisions_id` bigint(20) NOT NULL,
`decisions_ORDER` int(11) NOT NULL,
PRIMARY KEY (`RoughDraftApproval_id`,`decisions_ORDER`),
UNIQUE KEY `rough_draft_approval_uk` (`decisions_id`),
KEY `rough_draft_approval_decision_decisions` (`decisions_id`),
KEY `rough_draft_approval_decision_rough_draft` (`RoughDraftApproval_id`),
CONSTRAINT `rough_draft_approval_decision_rough_draft` FOREIGN KEY (`RoughDraftApproval_id`) REFERENCES `RoughDraftApproval` (`id`),
CONSTRAINT `rough_draft_approval_decision_decisions` FOREIGN KEY (`decisions_id`) REFERENCES `Decision` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -1,11 +0,0 @@
DROP TABLE `RoughDraftApproval_Decision`;
DROP TABLE `RoughDraftApproval`;
RENAME TABLE `FinalSeminarApproval` TO `ReviewerApproval`;
RENAME TABLE `FinalSeminarApproval_Decision` TO `ReviewerApproval_Decision`;
ALTER TABLE `ReviewerApproval_Decision` DROP FOREIGN KEY `FK_7g4wtjpvw81tv6hna7vwvu05f`;
ALTER TABLE `ReviewerApproval_Decision` CHANGE COLUMN `FinalSeminarApproval_id` `ReviewerApproval_id` bigint(20) not null;
ALTER TABLE `ReviewerApproval_Decision` ADD CONSTRAINT `FK_7g4wtjpvw81tv6hna7vwvu05f` FOREIGN KEY (`ReviewerApproval_id`) REFERENCES `ReviewerApproval` (`id`);
ALTER TABLE `ReviewerApproval` ADD COLUMN `type` varchar(64) not null;

@ -1 +0,0 @@
ALTER TABLE `AnnualReview` DROP COLUMN `year`;

@ -1,2 +0,0 @@
ALTER TABLE `project` DROP FOREIGN KEY `FK_draft`;
ALTER TABLE `project` DROP COLUMN `draft_id`;

@ -1 +0,0 @@
ALTER TABLE `FinalThesis` ADD COLUMN `dateApproved` DATE;

@ -1,5 +0,0 @@
INSERT INTO `Event`
(`name`, `description`)
VALUES
('Step.FINAL_SEMINAR_APPROVAL', 'The thesis is approved for final seminar by the reviewer'),
('Step.ROUGH_DRAFT_APPROVAL', 'Rough draft is approved by the reviewer');

@ -1,7 +0,0 @@
CREATE TABLE `ExternalResource` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`url` VARCHAR(255) NOT NULL,
`label` VARCHAR(255) NOT NULL,
`relevantFor_id` BIGINT(20) NOT NULL,
CONSTRAINT `ExternalResource_ProjectType_relevantFor` FOREIGN KEY (`relevantFor_id`) REFERENCES `ProjectType` (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;

@ -1 +0,0 @@
ALTER TABLE `notification_delivery_configuration` MODIFY COLUMN `event` VARCHAR(255) NOT NULL;

@ -1,11 +0,0 @@
-- Clean up
ALTER TABLE `username` DROP KEY `username`;
ALTER TABLE `username` DROP KEY `UK_s525no5d53h1qncd9n3vp3nfw`;
ALTER TABLE `username` DROP KEY `FKF02988D6895349BF`;
-- What the script should be doing
-- We skip usernames that already have a @ in them since they are most likely correct already
UPDATE `username` SET `username` = LOWER(CONCAT(`username`, '@', `realm`)) WHERE `username` NOT LIKE '%@%';
ALTER TABLE `username` DROP COLUMN `realm`;
ALTER TABLE `username` ADD UNIQUE KEY `username_must_be_unique` (`username`);

@ -1 +0,0 @@
ALTER TABLE `FinalSeminarSettings` ADD COLUMN `evaluationURL` LONGTEXT DEFAULT NULL;

@ -1,10 +0,0 @@
CREATE TABLE IF NOT EXISTS `footer_link` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`footerColumn` varchar(10) NOT NULL,
`title` varchar(255) NOT NULL,
`URL` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

@ -1 +0,0 @@
ALTER TABLE `Decision` MODIFY COLUMN `reason` LONGTEXT DEFAULT NULL;

@ -1,10 +0,0 @@
CREATE TABLE IF NOT EXISTS `reviewer_deadline_settings` (
`id` bigint(20) NOT NULL,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`roughDraftApproval` int(11) NOT NULL,
`finalSeminarApproval` int(11) NOT NULL,
`finalGrading` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -1,8 +0,0 @@
ALTER TABLE `ReviewerApproval` ADD (
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL
);
UPDATE `ReviewerApproval` SET `dateCreated` = NOW();
UPDATE `ReviewerApproval` SET `lastModified` = NOW();

@ -1 +0,0 @@
ALTER TABLE `FinalThesis` ADD COLUMN `dateRejected` DATE;

@ -1,9 +0,0 @@
CREATE TABLE IF NOT EXISTS `footer_address` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`address` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

@ -1,5 +0,0 @@
ALTER TABLE `Decision` ADD COLUMN `requested` DATETIME NOT NULL;
ALTER TABLE `Decision` ADD COLUMN `decisionDate` DATETIME DEFAULT NULL;
UPDATE `Decision` SET `requested` = (SELECT `dateCreated` FROM `file_description` WHERE `id` = `thesis_id`);
UPDATE `Decision` SET `decisionDate` = `requested` WHERE `status` != 'UNDECIDED';

@ -1 +0,0 @@
UPDATE `user_role` SET `role` = 'SUPERVISOR' WHERE `role` like 'EMPLOYEE';

@ -1 +0,0 @@
UPDATE `user_role` SET `role` = 'AUTHOR' WHERE `role` like 'STUDENT';

@ -1 +0,0 @@
ALTER TABLE `FinalSeminarSettings` ADD COLUMN `oppositionPriorityDays` INT NOT NULL;

@ -1,4 +0,0 @@
INSERT INTO `Language` (`dateCreated`, `lastModified`, `version`, `name`)
SELECT NOW(), NOW(), 0, 'Swedish' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `Language` WHERE `name` = 'Swedish');
INSERT INTO `Language` (`dateCreated`, `lastModified`, `version`, `name`)
SELECT NOW(), NOW(), 0, 'English' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `Language` WHERE `name` = 'English');

@ -1,9 +0,0 @@
ALTER TABLE `final_seminar` ADD COLUMN `reportLanguage_id` BIGINT(20) NOT NULL;
UPDATE `final_seminar` SET `reportLanguage_id` = (SELECT `id` FROM `Language` WHERE UPPER(`name`) = UPPER(`final_seminar`.`reportLanguage`));
ALTER TABLE `final_seminar` ADD CONSTRAINT `FK_final_seminar_report_language` FOREIGN KEY (`reportLanguage_id`) REFERENCES `Language` (`id`);
ALTER TABLE `final_seminar` DROP COLUMN `reportLanguage`;
ALTER TABLE `final_seminar` ADD COLUMN `presentationLanguage_id` BIGINT(20) NOT NULL;
UPDATE `final_seminar` SET `presentationLanguage_id` = (SELECT `id` FROM `Language` WHERE UPPER(`name`) = UPPER(`final_seminar`.`presentationLanguage`));
ALTER TABLE `final_seminar` ADD CONSTRAINT `FK_final_seminar_presentation_language` FOREIGN KEY (`presentationLanguage_id`) REFERENCES `Language` (`id`);
ALTER TABLE `final_seminar` DROP COLUMN `presentationLanguage`;

@ -1,4 +0,0 @@
ALTER TABLE `idea` ADD COLUMN `language_id` BIGINT(20) DEFAULT NULL;
UPDATE `idea` SET `language_id` = (SELECT `id` FROM `Language` WHERE UPPER(`name`) = UPPER(`idea`.`language`));
ALTER TABLE `idea` ADD CONSTRAINT `FK_idea_language` FOREIGN KEY (`language_id`) REFERENCES `Language` (`id`);
ALTER TABLE `idea` DROP COLUMN `language`;

@ -1,4 +0,0 @@
ALTER TABLE `user_languages` ADD COLUMN `language_id` BIGINT(20) NOT NULL;
UPDATE `user_languages` SET `language_id` = (SELECT `id` FROM `Language` WHERE UPPER(`name`) = UPPER(`user_languages`.`languages`));
ALTER TABLE `user_languages` ADD CONSTRAINT `FK_user_languages_language` FOREIGN KEY (`language_id`) REFERENCES `Language` (`id`);
ALTER TABLE `user_languages` DROP COLUMN `languages`;

@ -1,21 +0,0 @@
CREATE TABLE IF NOT EXISTS `group` (
`id` bigint(20) NOT NULL,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`title` varchar(250) NOT NULL,
`description` LONGTEXT,
`user_id` bigint(20) NOT NULL,
`active` bit(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `group_project` (
`group_id` bigint(20) NOT NULL,
`project_id` bigint(20) NOT NULL,
PRIMARY KEY (`group_id`, `project_id`),
KEY `FK_group_id` (`group_id`),
KEY `FK_project_id` (`project_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -1,28 +0,0 @@
DROP TABLE `group`, `group_project`;
CREATE TABLE IF NOT EXISTS `project_group` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`description` LONGTEXT,
`user_id` bigint(20) NOT NULL,
`active` bit(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
ALTER TABLE `project_group` ADD CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
CREATE TABLE IF NOT EXISTS `project_group_project` (
`project_group_id` bigint(20) NOT NULL,
`project_id` bigint(20) NOT NULL,
PRIMARY KEY (`project_group_id`, `project_id`),
KEY `FK_project_group_id` (`project_group_id`),
KEY `FK_project_id` (`project_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `project_group_project`
ADD CONSTRAINT `FK_project_group_id` FOREIGN KEY (`project_group_id`) REFERENCES `project_group` (`id`),
ADD CONSTRAINT `FK_project_id` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`);

@ -1 +0,0 @@
ALTER TABLE `general_system_settings` DROP `remoteExport` ;

@ -1,52 +0,0 @@
CREATE TABLE IF NOT EXISTS `group_thread` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`deleted` tinyint(1) NOT NULL,
`subject` varchar(255) NOT NULL,
`user` bigint(20) NOT NULL,
`project_group` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY (`deleted`),
KEY (`user`),
KEY (`project_group`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
ALTER TABLE `group_thread`
ADD CONSTRAINT FOREIGN KEY (`user`) REFERENCES `user` (`id`),
ADD CONSTRAINT FOREIGN KEY (`project_group`) REFERENCES `project_group` (`id`);
CREATE TABLE IF NOT EXISTS `group_post` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`lastModified` datetime NOT NULL,
`version` int(11) NOT NULL,
`deleted` tinyint(1) NOT NULL,
`content` LONGTEXT NOT NULL,
`user` bigint(20) NOT NULL,
`group_thread` bigint(20) NOT NULL,
`attachment` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY (`deleted`),
KEY (`user`),
KEY (`group_thread`),
KEY (`attachment`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
ALTER TABLE `group_post`
ADD CONSTRAINT FOREIGN KEY (`user`) REFERENCES `user` (`id`),
ADD CONSTRAINT FOREIGN KEY (`group_thread`) REFERENCES `group_thread` (`id`),
ADD CONSTRAINT FOREIGN KEY (`attachment`) REFERENCES `file_description` (`id`);
CREATE TABLE IF NOT EXISTS `group_thread_group_post` (
`group_thread` bigint(20) NOT NULL,
`group_post` bigint(20) NOT NULL,
PRIMARY KEY (`group_thread`, `group_post`),
KEY (`group_thread`),
KEY (`group_post`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `group_thread_group_post`
ADD CONSTRAINT FOREIGN KEY (`group_thread`) REFERENCES `group_thread` (`id`),
ADD CONSTRAINT FOREIGN KEY (`group_post`) REFERENCES `group_post` (`id`);

@ -1,5 +0,0 @@
CREATE TABLE `daisy_grading_report_export` (
gradingReport_id BIGINT(20) NOT NULL,
PRIMARY KEY (`gradingReport_id`),
CONSTRAINT `grading_report_export_grading_report` FOREIGN KEY (`gradingReport_id`) REFERENCES `grading_report` (`id`)
) ENGINE =InnoDB DEFAULT CHARSET =latin1;

Some files were not shown because too many files have changed in this diff Show More