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 50 additions and 6 deletions
Showing only changes of commit 340c72dd38 - Show all commits

View File

@ -1,15 +1,26 @@
package se.su.dsv.scipro.projectpartner;
import java.util.Objects;
import jakarta.persistence.Basic;
import jakarta.persistence.Cacheable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import se.su.dsv.scipro.match.ApplicationPeriod;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User;
import jakarta.persistence.*;
import java.util.Objects;
@Entity
@Table(name="projectPartner")
@Table(name="project_partner")
@Cacheable(true)
public class ProjectPartner extends DomainObject {
@Id
@ -20,9 +31,11 @@ public class ProjectPartner extends DomainObject {
private User user;
@ManyToOne(optional = false)
@JoinColumn(name = "project_type_id")
private ProjectType projectType;
@ManyToOne(optional = false)
@JoinColumn(name = "application_period_id")
private ApplicationPeriod applicationPeriod;
@Lob
@ -30,7 +43,7 @@ public class ProjectPartner extends DomainObject {
private String infotext;
@Basic(optional = false)
@Column(nullable = false, name = "active")
@Column(name = "active", nullable = false)
private boolean active = true;
public ProjectPartner(User user){

View File

@ -927,7 +927,7 @@ 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):
/* >>> STACK PUSH
* 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.
@ -943,6 +943,8 @@ alter table `project` rename column `projectType_id` to `project_type_id`;
* Foreign keys will be then added in reverse order, it's like a stack pop.
*/
-- 1st table group: target, projectPartner, ApplicationPeriodProjectType
-- table: target, except foreign key to coming table project_type, and application_period
alter table `target` drop foreign key `target_user_id`;
@ -962,8 +964,25 @@ alter table `target`
foreign key (user_id) references user(id)
on delete cascade on update cascade;
-- table: projectPartner, except foreign key to coming table project_type, and application_period
alter table `projectPartner` drop foreign key `FK_project_partner_project_type`;
alter table `projectPartner` drop foreign key `FK_ProjectPartner_ApplicationPeriod_applicationPeriod`;
alter table `projectPartner` drop foreign key `FK1882B6F895349BF`;
alter table `projectPartner` drop key `FK_ProjectPartner_ApplicationPeriod_applicationPeriod`;
alter table `projectPartner` drop key `FK_project_partner_project_type`;
alter table `projectPartner` drop key `FK1882B6F895349BF`;
rename table `projectPartner` to `project_partner`;
alter table `project_partner` rename column `infotext` to `info_text`;
alter table `project_partner` rename column `projectType_id` to `project_type_id`;
alter table `project_partner` rename column `applicationPeriod_id` to `application_period_id`;
alter table `project_partner`
add constraint fk_project_partner_user_id
foreign key (user_id) references user(id)
on delete cascade on update cascade;
@ -984,6 +1003,12 @@ alter table `target`
-- TODO: Add back all foreign key references to application_period
-- **********************************************************************************
-- add foreign key reference from project_partner to application_period
alter table `project_partner`
add constraint fk_project_partner_application_period_id
foreign key (application_period_id) references application_period(id)
on delete cascade on update cascade;
-- add foreign key reference from target to application_period
alter table `target`
add constraint fk_target_application_period_id
@ -999,6 +1024,12 @@ alter table `target`
-- TODO: Add back all foreign key references to project_type
-- **********************************************************************************
-- add foreign key reference from target to project_type
alter table `project_partner`
add constraint fk_project_partner_project_type_id
foreign key (project_type_id) references project_type(id)
on delete cascade on update cascade;
-- add foreign key reference from target to project_type
alter table `target`
add constraint fk_target_project_type_id