task/3382: Harmonisera tabellnamn #6

Merged
ansv7779 merged 104 commits from task/3382 into develop 2024-11-12 13:33:44 +01:00
2 changed files with 101 additions and 50 deletions
Showing only changes of commit 3b1281f4c4 - Show all commits

View File

@ -40,12 +40,13 @@ public class ChecklistTemplate extends DomainObject {
private List<ChecklistCategory> categories = new ArrayList<>(); private List<ChecklistCategory> categories = new ArrayList<>();
@ManyToMany @ManyToMany
@JoinTable(name = "checklist_template_ProjectType", @JoinTable(name = "checklist_template_project_type",
joinColumns = {@JoinColumn(name = "checklist_template_id")}, joinColumns = {@JoinColumn(name = "checklist_template_id")},
inverseJoinColumns = {@JoinColumn(name = "projectType_id")}) inverseJoinColumns = {@JoinColumn(name = "project_type_id")})
private Collection<ProjectType> projectTypes = new HashSet<>(); private Collection<ProjectType> projectTypes = new HashSet<>();
public ChecklistTemplate() { public ChecklistTemplate() {
} }
public ChecklistTemplate(String name, User creator) { public ChecklistTemplate(String name, User creator) {

View File

@ -411,9 +411,9 @@ rename table `FinalSeminarSettings` to `final_seminar_settings`;
-- table: general_system_settings_system_module -- table: general_system_settings_system_module
alter table `general_system_settings_system_modules` drop primary key;
alter table `general_system_settings_system_modules` drop foreign key `general_system_settings_system_modules_ibfk_1`; alter table `general_system_settings_system_modules` drop foreign key `general_system_settings_system_modules_ibfk_1`;
alter table `general_system_settings_system_modules` drop key `GeneralSystemSettings_id`; alter table `general_system_settings_system_modules` drop key `GeneralSystemSettings_id`;
alter table `general_system_settings_system_modules` drop primary key;
alter table `general_system_settings_system_modules` rename column `GeneralSystemSettings_id` to `general_system_settings_id`; alter table `general_system_settings_system_modules` rename column `GeneralSystemSettings_id` to `general_system_settings_id`;
alter table `general_system_settings_system_modules` rename column `systemModules` to `system_module`; alter table `general_system_settings_system_modules` rename column `systemModules` to `system_module`;
@ -493,7 +493,7 @@ alter table `general_system_settings` rename column `activeProjectIdeaSupportMai
* foreign key references end at table user. * foreign key references end at table user.
*/ */
-- table Program and user_program -- table: Program and user_program
alter table `user_program` drop foreign key `user_program_program_id`; alter table `user_program` drop foreign key `user_program_program_id`;
alter table `user_program` drop key `user_program_program_id`; alter table `user_program` drop key `user_program_program_id`;
@ -516,7 +516,7 @@ alter table `user_program`
foreign key (user_id) references user(id) foreign key (user_id) references user(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- table note -- table: note
alter table `note` drop foreign key `note_ibfk_1`; alter table `note` drop foreign key `note_ibfk_1`;
alter table `note` drop key `user_id`; alter table `note` drop key `user_id`;
@ -526,7 +526,7 @@ alter table `note`
foreign key (user_id) references user(id) foreign key (user_id) references user(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- table comment & comment_thread -- table: comment and comment_thread
alter table `comment` drop foreign key `FK38A5EE5FE44F4DBE`; alter table `comment` drop foreign key `FK38A5EE5FE44F4DBE`;
alter table `comment` drop foreign key `FK38A5EE5F45F802F5`; alter table `comment` drop foreign key `FK38A5EE5F45F802F5`;
@ -598,7 +598,7 @@ alter table `user_name`
foreign key (user_id) references user(id) foreign key (user_id) references user(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- table user_role -- table: user_role
alter table `user_role` drop foreign key `user_role_user_id`; alter table `user_role` drop foreign key `user_role_user_id`;
@ -607,7 +607,7 @@ alter table `user_role`
foreign key (user_id) references user(id) foreign key (user_id) references user(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- table user_language -- table: user_languages
alter table `user_languages` drop foreign key `user_languages_user_id`; alter table `user_languages` drop foreign key `user_languages_user_id`;
alter table `user_languages` drop key `user_languages_user_id`; alter table `user_languages` drop key `user_languages_user_id`;
@ -619,7 +619,9 @@ alter table `user_language`
foreign key (user_id) references user(id) foreign key (user_id) references user(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- table: user, unit and password /*
* table: user, unit and Password
*/
alter table `user` drop foreign key `FK_hpmviec1b7vdg23xtxsalwxw8`; alter table `user` drop foreign key `FK_hpmviec1b7vdg23xtxsalwxw8`;
alter table `user` drop key `FK_hpmviec1b7vdg23xtxsalwxw8`; alter table `user` drop key `FK_hpmviec1b7vdg23xtxsalwxw8`;
@ -641,7 +643,7 @@ alter table `user` rename column `degreeType` to `degree_type`;
alter table `user` add constraint uk_user_identifier unique(identifier); alter table `user` add constraint uk_user_identifier unique(identifier);
create index idx_user_deleted on user(deleted); create index idx_user_deleted on user(deleted);
-- fix table unit -- table: unit
alter table `unit` drop key `identifier`; alter table `unit` drop key `identifier`;
@ -656,7 +658,7 @@ alter table `user`
foreign key (unit_id) references unit(id) foreign key (unit_id) references unit(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- fix table password -- table: Password
alter table `Password` drop foreign key `FK_43erxladp39q03wrco68hi9iq`; alter table `Password` drop foreign key `FK_43erxladp39q03wrco68hi9iq`;
alter table `Password` drop key `FK_43erxladp39q03wrco68hi9iq`; alter table `Password` drop key `FK_43erxladp39q03wrco68hi9iq`;
@ -682,7 +684,7 @@ alter table `user`
foreign key (password_id) references password(id) foreign key (password_id) references password(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- fix table user_profile -- table: user_profile
alter table `user_profile` drop foreign key `FK_user_profile_user`; alter table `user_profile` drop foreign key `FK_user_profile_user`;
alter table `user_profile` drop key `FK487E2135895349BF`; alter table `user_profile` drop key `FK487E2135895349BF`;
@ -704,7 +706,7 @@ alter table `user_profile`
foreign key (user_id) references user(id) foreign key (user_id) references user(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- fix table user_profile_default_project_status_filter -- table: user_profile_default_project_status_filter
alter table `UserProfile_defaultProjectStatusFilter` drop foreign key `FK_user_profile_project_status_user_profile`; alter table `UserProfile_defaultProjectStatusFilter` drop foreign key `FK_user_profile_project_status_user_profile`;
alter table `UserProfile_defaultProjectStatusFilter` drop key `FK_icub74l6htav89sx85ar4qcqg`; alter table `UserProfile_defaultProjectStatusFilter` drop key `FK_icub74l6htav89sx85ar4qcqg`;
@ -719,7 +721,7 @@ alter table `user_profile_default_project_status_filter`
foreign key (user_profile_id) references user_profile(id) foreign key (user_profile_id) references user_profile(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- fix table user_profile_default_project_team_member_roles_filter -- table: user_profile_default_project_team_member_roles_filter
alter table `UserProfile_defaultProjectTeamMemberRolesFilter` drop foreign key `FK_user_profile_role_user_profile`; alter table `UserProfile_defaultProjectTeamMemberRolesFilter` drop foreign key `FK_user_profile_role_user_profile`;
alter table `UserProfile_defaultProjectTeamMemberRolesFilter` drop key `FK_ibub74l6htav89sx85ar4qcqg`; alter table `UserProfile_defaultProjectTeamMemberRolesFilter` drop key `FK_ibub74l6htav89sx85ar4qcqg`;
@ -734,14 +736,21 @@ alter table `user_profile_default_project_team_member_roles_filter`
foreign key (user_profile_id) references user_profile(id) foreign key (user_profile_id) references user_profile(id)
on delete cascade on update cascade; on delete cascade on update cascade;
/* *********************************************************************************************** */ /*
/* Table ProjectType and all tables which reference to ProjectType... */ * Step 6: table ProjectType and related tables.
*
* Table ProjectType is one of four fundamental tables (other three: project, file_reference, user). All four
* tables have many foreign keys referenced to them.
*
* Table ProjectType has 12 foreign keys referenced to it, this part is the most complex part of this refactoring.
*/
-- fix table user_profile_ProjectType except foreign key to table project_type -- table: user_profile_ProjectType except foreign key to coming table project_type
alter table `user_profile_ProjectType` drop foreign key `FK_user_profile_project_type_user_profile`; alter table `user_profile_ProjectType` drop foreign key `FK_user_profile_project_type_user_profile`;
alter table `user_profile_ProjectType` drop foreign key `FK_76s8320kw3w7bxp6lw7pmawfh`; alter table `user_profile_ProjectType` drop foreign key `FK_76s8320kw3w7bxp6lw7pmawfh`;
alter table `user_profile_ProjectType` drop key `FK_2blea2vk0b5cvgxjo1fy4p2j0`; alter table `user_profile_ProjectType` drop key `FK_2blea2vk0b5cvgxjo1fy4p2j0`;
alter table `user_profile_ProjectType` drop key `FK_76s8320kw3w7bxp6lw7pmawfh`;
rename table `user_profile_ProjectType` to `user_profile_project_type`; rename table `user_profile_ProjectType` to `user_profile_project_type`;
@ -752,18 +761,20 @@ alter table `user_profile_project_type`
foreign key (user_profile_id) references user_profile(id) foreign key (user_profile_id) references user_profile(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- fix table external_resource except foreign key to table project_type -- table: ExternalResource except foreign key to coming table project_type
alter table `ExternalResource` drop foreign key `ExternalResource_ProjectType_relevantFor`; alter table `ExternalResource` drop foreign key `ExternalResource_ProjectType_relevantFor`;
alter table `ExternalResource` drop key `ExternalResource_ProjectType_relevantFor`;
rename table `ExternalResource` to `external_resource`; rename table `ExternalResource` to `external_resource`;
alter table `external_resource` rename column `relevantFor_id` to `project_type_id`; alter table `external_resource` rename column `relevantFor_id` to `project_type_id`;
-- fix table project_type_project_modules except foreign key to table project_type -- table: project_type_project_modules except foreign key to coming table project_type
alter table `project_type_project_modules` drop primary key;
alter table `project_type_project_modules` drop foreign key `FK_4attsf1e22qpveesgl6o9b7lg`; alter table `project_type_project_modules` drop foreign key `FK_4attsf1e22qpveesgl6o9b7lg`;
alter table `project_type_project_modules` drop key `FK_4attsf1e22qpveesgl6o9b7lg`;
alter table `project_type_project_modules` drop primary key;
rename table `project_type_project_modules` to `project_type_project_module`; rename table `project_type_project_modules` to `project_type_project_module`;
@ -774,10 +785,11 @@ alter table `project_type_project_module`
add constraint pk_project_type_project_module add constraint pk_project_type_project_module
primary key(project_type_id, project_module); primary key(project_type_id, project_module);
-- fix table project_type_settings except foreign key to table project_type -- table: project_type_settings except foreign key to coming table project_type
alter table `project_type_settings` drop foreign key `FK_oxqyb1t8jo7cq2fx8j9slvloa`; alter table `project_type_settings` drop foreign key `FK_oxqyb1t8jo7cq2fx8j9slvloa`;
alter table `project_type_settings` drop foreign key `FK_project_class_settings_projectType`; alter table `project_type_settings` drop foreign key `FK_project_class_settings_projectType`;
alter table `project_type_settings` drop key `FK_oxqyb1t8jo7cq2fx8j9slvloa`;
alter table `project_type_settings` drop key `UK_project_class_settings_projectType`; alter table `project_type_settings` drop key `UK_project_class_settings_projectType`;
alter table `project_type_settings` rename column `numDaysBetweenPeerReviewsOnSameProject` to `num_days_between_peer_reviews_on_same_project`; alter table `project_type_settings` rename column `numDaysBetweenPeerReviewsOnSameProject` to `num_days_between_peer_reviews_on_same_project`;
@ -795,48 +807,31 @@ alter table `project_type_settings` rename column `minimumActiveParticipationsTo
alter table `project_type_settings` add constraint uk_project_type_settings_project_type_id unique(project_type_id); alter table `project_type_settings` add constraint uk_project_type_settings_project_type_id unique(project_type_id);
-- fix table grading_report_template except foreign key to table project_type -- table: grading_report_template except foreign key to coming table project_type
alter table `grading_report_template` drop foreign key `FK_grading_report_template_projectType`; alter table `grading_report_template` drop foreign key `FK_grading_report_template_projectType`;
alter table `grading_report_template` drop key `FK_qovbb9ql33oaxprfr01w7ss9u`; alter table `grading_report_template` drop key `FK_qovbb9ql33oaxprfr01w7ss9u`;
alter table `grading_report_template` rename column `projectType_id` to `project_type_id`; alter table `grading_report_template` rename column `projectType_id` to `project_type_id`;
-- fix table GradingCriterionPoint (partially, only rename two columns since this table and grading_criterion_pint_template /* >>> START: tables grading_criterion_template, GradingCriterion and criterion share same JPA MappedSuperclass, must be handled together. */
-- shares same MappedSuperclass AbstractGradingCriterionPoint. JPA-mapping is defined at AbstractGradingCriterionPoint
alter table `GradingCriterionPoint` rename column `description` to `description_sv`; -- table: criterion (partially, only rename three columns, since this table criterion shares same
alter table `GradingCriterionPoint` rename column `descriptionEn` to `description_en`; -- JPA MappedSuperclass AbstractCriterion with grading_criterion_template, and GradingCriterion
-- fix table grading_criterion_point_template
alter table `grading_criterion_point_template` drop foreign key `FK_gradingCriterionTemplate_id`;
alter table `grading_criterion_point_template` rename column `description` to `description_sv`;
alter table `grading_criterion_point_template` rename column `descriptionEn` to `description_en`;
alter table `grading_criterion_point_template` rename column `gradingCriterionTemplate_id` to `grading_criterion_template_id`;
alter table `grading_criterion_point_template`
add constraint fk_gc_pt_grading_criterion_template_id
foreign key(grading_criterion_template_id) references grading_criterion_template(id)
on delete cascade on update cascade;
-- fix table criterion (partially, only rename three columns, since this table criterion shares same
-- JPA MappedSuperclass AbstractCriterion
alter table `criterion` rename column `title` to `title_sv`; alter table `criterion` rename column `title` to `title_sv`;
alter table `criterion` rename column `titleEn` to `title_en`; alter table `criterion` rename column `titleEn` to `title_en`;
alter table `criterion` rename column `sortOrder` to `sort_order`; alter table `criterion` rename column `sortOrder` to `sort_order`;
-- fix table GradingCriterion (partially, only rename four columns, since this table GradingCriterion shares same -- table: GradingCriterion (partially, only rename four columns, since this table GradingCriterion shares same
-- JPA MappedSuperclass AbstractCriterion and AbstractGradingCriterion. -- JPA MappedSuperclass AbstractCriterion and AbstractGradingCriterion with grading_criterion_template.
alter table `GradingCriterion` rename column `title` to `title_sv`; alter table `GradingCriterion` rename column `title` to `title_sv`;
alter table `GradingCriterion` rename column `titleEn` to `title_en`; alter table `GradingCriterion` rename column `titleEn` to `title_en`;
alter table `GradingCriterion` rename column `sortOrder` to `sort_order`; alter table `GradingCriterion` rename column `sortOrder` to `sort_order`;
alter table `GradingCriterion` rename column `pointsRequiredToPass` to `points_required_to_pass`; alter table `GradingCriterion` rename column `pointsRequiredToPass` to `points_required_to_pass`;
-- fix table grading_criterion_template -- table: grading_criterion_template
alter table `grading_criterion_template` drop foreign key `FK_b37xw6uyfj98ff2tsn5t8x5q`; alter table `grading_criterion_template` drop foreign key `FK_b37xw6uyfj98ff2tsn5t8x5q`;
alter table `grading_criterion_template` drop key `FK_b37xw6uyfj98ff2tsn5t8x5q`; alter table `grading_criterion_template` drop key `FK_b37xw6uyfj98ff2tsn5t8x5q`;
@ -849,31 +844,85 @@ alter table `grading_criterion_template` rename column `gradingReportTemplate_id
alter table `grading_criterion_template` alter table `grading_criterion_template`
add constraint fk_gct_grading_report_template_id add constraint fk_gct_grading_report_template_id
foreign key(grading_report_template_id) references grading_report_template(id) foreign key (grading_report_template_id) references grading_report_template(id)
on delete cascade on update cascade;
/* >>> END: */
/* >>> START: tables grading_criterion_point_template and GradingCriterionPoint share same JPA MappedSuperclass, must be handled together. */
-- table: GradingCriterionPoint (partially, only rename two columns since this table and grading_criterion_pint_template
-- shares same MappedSuperclass AbstractGradingCriterionPoint.
alter table `GradingCriterionPoint` rename column `description` to `description_sv`;
alter table `GradingCriterionPoint` rename column `descriptionEn` to `description_en`;
-- table: grading_criterion_point_template
alter table `grading_criterion_point_template` drop foreign key `FK_gradingCriterionTemplate_id`;
alter table `grading_criterion_point_template` drop key `FK_gradingCriterionTemplate_id`;
alter table `grading_criterion_point_template` rename column `description` to `description_sv`;
alter table `grading_criterion_point_template` rename column `descriptionEn` to `description_en`;
alter table `grading_criterion_point_template` rename column `gradingCriterionTemplate_id` to `grading_criterion_template_id`;
alter table `grading_criterion_point_template`
add constraint fk_gc_pt_grading_criterion_template_id
foreign key (grading_criterion_template_id) references grading_criterion_template(id)
on delete cascade on update cascade; on delete cascade on update cascade;
/* >>> END: */
-- table: checklist_template_ProjectType except foreign key to coming table project_type
alter table `checklist_template_ProjectType` drop foreign key `FK_checklist_template_projectType_id`;
alter table `checklist_template_ProjectType` drop foreign key `FK_checklist_template_degree_level_checklist_template_id`;
alter table `checklist_template_ProjectType` drop key `FK_checklist_template_projectType_id`;
alter table `checklist_template_ProjectType` drop primary key;
rename table `checklist_template_ProjectType` to `checklist_template_project_type`;
alter table `checklist_template_project_type` rename column `projectType_id` to `project_type_id`;
alter table `checklist_template_project_type` add primary key (checklist_template_id, project_type_id);
alter table `checklist_template_project_type`
add constraint fk_ct_pt_checklist_template_id
foreign key (checklist_template_id) references checklist_template(id)
on delete cascade on update cascade;
/* Activate following later /* Activate following later
-- fix table ProjectType -- **********************************************************************************
-- TODO: fix table ProjectType, verify no foreign keys are referenced to ProjectTYpe
-- **********************************************************************************
-- Add back all foreign key references to project_typ
-- add foreign key reference from checklist_template_project_type to project_type
alter table `checklist_template_project_type`
add constraint fk_ct_pt_project_type_id
foreign key (fk_ct_pt_project_type_id) references project_type(id)
on delete cascade on update cascade;
-- add foreign key reference from grading_report_template to project_type -- add foreign key reference from grading_report_template to project_type
alter table `grading_report_template` alter table `grading_report_template`
add constraint fk_grading_report_template_project_type_id add constraint fk_grading_report_template_project_type_id
foreign key(project_type_id) references project_type(id) foreign key (project_type_id) references project_type(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- add foreign key reference from project_type_settings to project_type -- add foreign key reference from project_type_settings to project_type
alter table `project_type_settings` alter table `project_type_settings`
add constraint fk_project_type_settings_project_type_id add constraint fk_project_type_settings_project_type_id
foreign key(project_type_id) references project_type(id) foreign key (project_type_id) references project_type(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- add foreign key reference from project_type_project_module to project_type -- add foreign key reference from project_type_project_module to project_type
alter table `project_type_project_module` alter table `project_type_project_module`
add constraint fk_project_type_project_module_project_type_id add constraint fk_project_type_project_module_project_type_id
foreign key(project_type_id) references project_type(id) foreign key (project_type_id) references project_type(id)
on delete cascade on update cascade; on delete cascade on update cascade;
-- add foreign key reference from external_resource to project_type -- add foreign key reference from external_resource to project_type
@ -899,6 +948,7 @@ alter table `user_profile_project_type`
where table_schema = 'tozh4728' and where table_schema = 'tozh4728' and
referenced_table_name = 'ProjectType'; referenced_table_name = 'ProjectType';
SQL query for FK-to count:
select referenced_table_name, count(*) as c select referenced_table_name, count(*) as c
from key_column_usage from key_column_usage
where table_schema = 'tozh4728' and where table_schema = 'tozh4728' and