task/3382: Harmonisera tabellnamn #6
@ -1,15 +1,23 @@
|
|||||||
package se.su.dsv.scipro.match;
|
package se.su.dsv.scipro.match;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import jakarta.persistence.AttributeOverride;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.EmbeddedId;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.MapsId;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "applicationperiodexemption")
|
@Table(name = "application_period_exemption")
|
||||||
public class ApplicationPeriodExemption implements Serializable {
|
public class ApplicationPeriodExemption implements Serializable {
|
||||||
public enum Type {
|
public enum Type {
|
||||||
SUBMIT_STUDENT_IDEA(true),
|
SUBMIT_STUDENT_IDEA(true),
|
||||||
@ -39,16 +47,19 @@ public class ApplicationPeriodExemption implements Serializable {
|
|||||||
|
|
||||||
@MapsId("applicationPeriodId")
|
@MapsId("applicationPeriodId")
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
@JoinColumn(name = "applicationPeriodId")
|
@JoinColumn(name = "application_period_id")
|
||||||
private ApplicationPeriod applicationPeriod;
|
private ApplicationPeriod applicationPeriod;
|
||||||
|
|
||||||
|
@Column(name = "end_date")
|
||||||
private LocalDate endDate;
|
private LocalDate endDate;
|
||||||
|
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
|
@JoinColumn(name = "granted_by_id")
|
||||||
private User grantedBy;
|
private User grantedBy;
|
||||||
|
|
||||||
|
@Column(name = "granted_on")
|
||||||
private LocalDateTime grantedOn;
|
private LocalDateTime grantedOn;
|
||||||
|
|
||||||
public ApplicationPeriodExemptionId getApplicationperiodexemptionId() {
|
public ApplicationPeriodExemptionId getApplicationperiodexemptionId() {
|
||||||
|
@ -916,7 +916,6 @@ alter table `milestone_activity_template_project_type`
|
|||||||
alter table `idea` drop foreign key `FK_idea_projectType`;
|
alter table `idea` drop foreign key `FK_idea_projectType`;
|
||||||
alter table `idea` drop key `FK_idea_projectType`;
|
alter table `idea` drop key `FK_idea_projectType`;
|
||||||
|
|
||||||
alter table `idea` rename column `projectType_id` to `project_type_id`;
|
|
||||||
alter table `idea` rename column `projectType_id` to `project_type_id`;
|
alter table `idea` rename column `projectType_id` to `project_type_id`;
|
||||||
|
|
||||||
-- table: project, we only remove foreign key from project to ProjectType and rename the column projectType_id here.
|
-- table: project, we only remove foreign key from project to ProjectType and rename the column projectType_id here.
|
||||||
@ -934,13 +933,14 @@ alter table `project` rename column `projectType_id` to `project_type_id`;
|
|||||||
*
|
*
|
||||||
* Table ActivityTemplate, ActivityPlanTemplate, ApplicationPeriod using camel case naming convention,
|
* Table ActivityTemplate, ActivityPlanTemplate, ApplicationPeriod using camel case naming convention,
|
||||||
* ApplicationPeriod has a related table, applicationperiodexemption, and they all need to
|
* ApplicationPeriod has a related table, applicationperiodexemption, and they all need to
|
||||||
* fixed as well, before ProjectType can be fixed.
|
* fixed as well, before ProjectType can be fixed. A foreign key from table idea to ApplicationPeriod needs to be removed
|
||||||
|
* before table ApplicationPeriod can be fixed.
|
||||||
*
|
*
|
||||||
* Removal of foreign keys and renaming of columns and table name must be fixed in following order:
|
* Removal of foreign keys and renaming of columns and table name must be fixed in following order:
|
||||||
*
|
*
|
||||||
* 1. target, projectPartner, ApplicationPeriodProjectType
|
* 1. target, projectPartner, ApplicationPeriodProjectType
|
||||||
* 2. ActivityTemplate and ActivityPlanTemplate
|
* 2. ActivityTemplate and ActivityPlanTemplate
|
||||||
* 3. ApplicationPeriod and applicationperiodexcemption
|
* 3. ApplicationPeriod, applicationperiodexcemption, and idea as well
|
||||||
*
|
*
|
||||||
* Foreign keys will be then added in reverse order, it's like a stack pop.
|
* Foreign keys will be then added in reverse order, it's like a stack pop.
|
||||||
*/
|
*/
|
||||||
@ -1058,32 +1058,78 @@ alter table `application_period_project_type`
|
|||||||
|
|
||||||
-- >>> STACK POP: 2nd table group (ActivityPlanTemplate and ActivityTemplate) is done!!!
|
-- >>> STACK POP: 2nd table group (ActivityPlanTemplate and ActivityTemplate) is done!!!
|
||||||
|
|
||||||
|
-- >>> STACK PUSH: 3rd table group: ApplicationPeriod, applicationperiodexemption, idea
|
||||||
|
|
||||||
|
-- table: applicationperiodexeption, except foreign key reference to coming table application_period
|
||||||
|
|
||||||
|
alter table `applicationperiodexemption` drop foreign key `fk_application_period_exemption_user`;
|
||||||
|
alter table `applicationperiodexemption` drop foreign key `fk_application_period_exemption_application_period`;
|
||||||
|
alter table `applicationperiodexemption` drop foreign key `FK_4p3he5fymtmdgbkl3xwrodq36`;
|
||||||
|
alter table `applicationperiodexemption` drop key `i_user_application_period`;
|
||||||
|
alter table `applicationperiodexemption` drop key `i_application_period`;
|
||||||
|
alter table `applicationperiodexemption` drop key `i_user`;
|
||||||
|
alter table `applicationperiodexemption` drop key `FK_4p3he5fymtmdgbkl3xwrodq36`;
|
||||||
|
alter table `applicationperiodexemption` drop primary key;
|
||||||
|
|
||||||
|
rename table `applicationperiodexemption` to `application_period_exemption`;
|
||||||
|
|
||||||
|
alter table `application_period_exemption` rename column `endDate` to `end_date`;
|
||||||
|
alter table `application_period_exemption` rename column `grantedBy_id` to `granted_by_id`;
|
||||||
|
alter table `application_period_exemption` rename column `grantedOn` to `granted_on`;
|
||||||
|
alter table `application_period_exemption` rename column `applicationPeriodId` to `application_period_id`;
|
||||||
|
|
||||||
|
alter table `application_period_exemption` add primary key (`application_period_id`,`user_id`,`type`);
|
||||||
|
|
||||||
|
alter table `application_period_exemption`
|
||||||
|
add constraint fk_ape_user_id
|
||||||
|
foreign key (user_id) references user (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
alter table `application_period_exemption`
|
||||||
|
add constraint fk_ape_granted_by_id
|
||||||
|
foreign key (granted_by_id) references user (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- table: idea, we only remove foreign key from idea to ApplicationPeriod and rename the column applicationPeriod_id here.
|
||||||
|
-- This table has many related tables and will be fixed later.
|
||||||
|
|
||||||
|
alter table `idea` drop foreign key `FK6E051897BEC322C1`;
|
||||||
|
alter table `idea` drop key `FK6E051897BEC322C1`;
|
||||||
|
|
||||||
|
alter table `idea` rename column `applicationPeriod_id` to `application_period_id`;
|
||||||
|
|
||||||
|
-- table: ApplicationPeriod, verify no foreign keys are referenced to ApplicationPeriod before fix it
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Activate following later
|
/* 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
|
-- TODO: -- Add back all foreign key references to application_period
|
||||||
-- **********************************************************************************
|
-- **********************************************************************************
|
||||||
|
|
||||||
-- add foreign key reference from application_period_project_type to application_period
|
-- add back foreign key reference from application_period_exemption to application_period
|
||||||
|
alter table `application_period_exemption`
|
||||||
|
add constraint fk_ape_application_period_id
|
||||||
|
foreign key (application_period_id) references application_period (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- add back foreign key reference from application_period_project_type to application_period
|
||||||
alter table `application_period_project_type`
|
alter table `application_period_project_type`
|
||||||
add constraint fk_ap_pt_application_period_id
|
add constraint fk_ap_pt_application_period_id
|
||||||
foreign key (application_period_id) references application_period (id)
|
foreign key (application_period_id) references application_period (id)
|
||||||
on delete cascade on update cascade;
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
-- add foreign key reference from project_partner to application_period
|
-- add back foreign key reference from project_partner to application_period
|
||||||
alter table `project_partner`
|
alter table `project_partner`
|
||||||
add constraint fk_project_partner_application_period_id
|
add constraint fk_project_partner_application_period_id
|
||||||
foreign key (application_period_id) references application_period (id)
|
foreign key (application_period_id) references application_period (id)
|
||||||
on delete cascade on update cascade;
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
-- add foreign key reference from target to application_period
|
-- add back foreign key reference from target to application_period
|
||||||
alter table `target`
|
alter table `target`
|
||||||
add constraint fk_target_application_period_id
|
add constraint fk_target_application_period_id
|
||||||
foreign key (application_period_id) references application_period (id)
|
foreign key (application_period_id) references application_period (id)
|
||||||
@ -1098,73 +1144,73 @@ alter table `target`
|
|||||||
-- TODO: -- Add back all foreign key references to project_type
|
-- TODO: -- Add back all foreign key references to project_type
|
||||||
-- **********************************************************************************
|
-- **********************************************************************************
|
||||||
|
|
||||||
-- add foreign key reference from target to project_type
|
-- add back foreign key reference from target to project_type
|
||||||
alter table `application_period_project_type`
|
alter table `application_period_project_type`
|
||||||
add constraint fk_ap_pt_project_type_id
|
add constraint fk_ap_pt_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 target to project_type
|
-- add back foreign key reference from target to project_type
|
||||||
alter table `project_partner`
|
alter table `project_partner`
|
||||||
add constraint fk_project_partner_project_type_id
|
add constraint fk_project_partner_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 target to project_type
|
-- add back foreign key reference from target to project_type
|
||||||
alter table `target`
|
alter table `target`
|
||||||
add constraint fk_target_project_type_id
|
add constraint fk_target_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 to project_type
|
-- add back foreign key reference from project to project_type
|
||||||
alter table `project`
|
alter table `project`
|
||||||
add constraint fk_project_project_type_id
|
add constraint fk_project_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 idea to project_type
|
-- add back foreign key reference from idea to project_type
|
||||||
alter table `idea`
|
alter table `idea`
|
||||||
add constraint fk_idea_project_type_id
|
add constraint fk_idea_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 milestone_activity_template_project_type to project_type
|
-- add back foreign key reference from milestone_activity_template_project_type to project_type
|
||||||
alter table `milestone_activity_template_project_type`
|
alter table `milestone_activity_template_project_type`
|
||||||
add constraint fk_ma_tpt_project_type_id
|
add constraint fk_ma_tpt_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 checklist_template_project_type to project_type
|
-- add back foreign key reference from checklist_template_project_type to project_type
|
||||||
alter table `checklist_template_project_type`
|
alter table `checklist_template_project_type`
|
||||||
add constraint fk_ct_pt_project_type_id
|
add constraint fk_ct_pt_project_type_id
|
||||||
foreign key (fk_ct_pt_project_type_id) references project_type (id)
|
foreign key (fk_ct_pt_project_type_id) references project_type (id)
|
||||||
on delete cascade on update cascade;
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
-- add foreign key reference from grading_report_template to project_type
|
-- add back 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 back 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 back 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 back foreign key reference from external_resource to project_type
|
||||||
alter table `external_resource`
|
alter table `external_resource`
|
||||||
add constraint fk_external_resource_project_type_id
|
add constraint fk_external_resource_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 user_profile_project_type to project_type.
|
-- add back foreign key reference from user_profile_project_type to project_type.
|
||||||
alter table `user_profile_project_type`
|
alter table `user_profile_project_type`
|
||||||
add constraint fk_user_profile_project_type_project_type_id
|
add constraint fk_user_profile_project_type_project_type_id
|
||||||
foreign key (project_type_id) references project_type (id)
|
foreign key (project_type_id) references project_type (id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user