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 79 additions and 12 deletions
Showing only changes of commit ae86b54692 - Show all commits

View File

@ -20,12 +20,12 @@ public class Target implements Serializable {
@MapsId("applicationPeriodId")
@ManyToOne
@JoinColumn(name = "applicationPeriodId")
@JoinColumn(name = "application_period_id")
private ApplicationPeriod applicationPeriod;
@MapsId("projectTypeId")
@ManyToOne
@JoinColumn(name = "projectTypeId")
@JoinColumn(name = "project_type_id")
private ProjectType projectType;
private int target;

View File

@ -745,7 +745,7 @@ alter table `user_profile_default_project_team_member_roles_filter`
* Table ProjectType has 12 foreign keys referenced to it, this part is the most complex part of this refactoring.
*/
-- table: user_profile_ProjectType except foreign key to coming 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_76s8320kw3w7bxp6lw7pmawfh`;
@ -761,7 +761,7 @@ alter table `user_profile_project_type`
foreign key (user_profile_id) references user_profile(id)
on delete cascade on update cascade;
-- table: ExternalResource except foreign key to coming 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 key `ExternalResource_ProjectType_relevantFor`;
@ -770,7 +770,7 @@ rename table `ExternalResource` to `external_resource`;
alter table `external_resource` rename column `relevantFor_id` to `project_type_id`;
-- table: project_type_project_modules except foreign key to coming table project_type
-- table: project_type_project_modules, except foreign key to coming table project_type
alter table `project_type_project_modules` drop foreign key `FK_4attsf1e22qpveesgl6o9b7lg`;
alter table `project_type_project_modules` drop key `FK_4attsf1e22qpveesgl6o9b7lg`;
@ -785,7 +785,7 @@ alter table `project_type_project_module`
add constraint pk_project_type_project_module
primary key(project_type_id, project_module);
-- table: project_type_settings except foreign key to coming 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_project_class_settings_projectType`;
@ -807,14 +807,14 @@ 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);
-- table: grading_report_template except foreign key to coming 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 key `FK_qovbb9ql33oaxprfr01w7ss9u`;
alter table `grading_report_template` rename column `projectType_id` to `project_type_id`;
/* >>> START: tables grading_criterion_template, GradingCriterion and criterion share same JPA MappedSuperclass, must be handled together. */
/* >>> START: table grading_criterion_template, GradingCriterion and criterion share same JPA MappedSuperclass, must be handled together. */
-- table: criterion (partially, only rename three columns, since this table criterion shares same
-- JPA MappedSuperclass AbstractCriterion with grading_criterion_template, and GradingCriterion
@ -849,7 +849,7 @@ alter table `grading_criterion_template`
/* >>> END: */
/* >>> START: tables grading_criterion_point_template and GradingCriterionPoint share same JPA MappedSuperclass, must be handled together. */
/* >>> START: table 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.
@ -873,7 +873,7 @@ alter table `grading_criterion_point_template`
/* >>> END: */
-- table: checklist_template_ProjectType except foreign key to coming table project_type
-- 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`;
@ -891,7 +891,7 @@ alter table `checklist_template_project_type`
foreign key (checklist_template_id) references checklist_template(id)
on delete cascade on update cascade;
-- table: milestone_activity_template_ProjectType except foreign key to coming table project_type
-- table: milestone_activity_template_ProjectType, except foreign key to coming table project_type
alter table `milestone_activity_template_ProjectType` drop foreign key `milestone_activity_template_ProjectType_ibfk_1`;
alter table `milestone_activity_template_ProjectType` drop foreign key `FKFB3FC75157F6B071`;
@ -927,16 +927,83 @@ alter table `project` drop key `FKED904B19B2B6081F`;
alter table `project` rename column `projectType_id` to `project_type_id`;
/* >>> STACK PUSH (1st table group: target, projectPartner, ApplicationPeriodProjectType):
* table target, projectPartner and ApplicationPeriodProjectType has not only foreign key referencing table ProjectType,
* but also foreign key referencing table ApplicationPeriod. Table ApplicationPeriodProjectType references to
* ActivityPlanTemplate as well.
* Table ActivityTemplate, ActivityPlanTemplate, ApplicationPeriod using camel case naming convention,
* ApplicationPeriod has a related table, applicationperiodexemption, and they all need to
* fixed as well, before ProjectType can be fixed.
* Removal of foreign keys and renaming of columns and table name must be fixed in following order:
*
* 1. target, projectPartner, ApplicationPeriodProjectType
* 2. ActivityTemplate and ActivityPlanTemplate
* 3. ApplicationPeriod and applicationperiodexcemption
*
* Foreign keys will be then added in reverse order, it's like a stack pop.
*/
-- table: target, except foreign key to coming table project_type, and application_period
alter table `target` drop foreign key `target_user_id`;
alter table `target` drop foreign key `FKCB7E7191A520201Eb`;
alter table `target` drop foreign key `FKCB7E7191790761A4b`;
alter table `target` drop key `FKCB7E7191A520201E`;
alter table `target` drop key `FKCB7E7191790761A4`;
alter table `target` drop primary key;
alter table `target` rename column `applicationPeriodId` to `application_period_id`;
alter table `target` rename column `projectTypeId` to `project_type_id`;
alter table `target` add primary key (application_period_id, project_type_id, user_id);
alter table `target`
add constraint fk_target_user_id
foreign key (user_id) references user(id)
on delete cascade on update cascade;
/* Activate following later
-- **********************************************************************************
-- TODO: fix table ApplicationPeriod, verify no foreign keys are referenced to ApplicationPeriod before fix it
-- **********************************************************************************
-- **********************************************************************************
-- TODO: Add back all foreign key references to application_period
-- **********************************************************************************
-- add foreign key reference from target to application_period
alter table `target`
add constraint fk_target_application_period_id
foreign key (application_period_id) references application_period(id)
on delete cascade on update cascade;
-- **********************************************************************************
-- TODO: fix table ProjectType, verify no foreign keys are referenced to ProjectTYpe before fix it
-- **********************************************************************************
-- Add back all foreign key references to project_typ
-- **********************************************************************************
-- TODO: Add back all foreign key references to project_type
-- **********************************************************************************
-- add foreign key reference from target to project_type
alter table `target`
add constraint fk_target_project_type_id
foreign key (project_type_id) references project_type(id)
on delete cascade on update cascade;
-- add foreign key reference from project to project_type
alter table `project`