task/3382: Harmonisera tabellnamn #6
|
@ -1,12 +1,24 @@
|
|||
package se.su.dsv.scipro.activityplan;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
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.checklist.ChecklistTemplate;
|
||||
import se.su.dsv.scipro.system.DomainObject;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "activity_template")
|
||||
public class ActivityTemplate extends DomainObject {
|
||||
|
||||
@Id
|
||||
|
@ -20,18 +32,20 @@ public class ActivityTemplate extends DomainObject {
|
|||
private String description;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "activity_plan_template_id")
|
||||
private ActivityPlanTemplate activityPlanTemplate;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Column(name = "days_offset", nullable = false)
|
||||
private int daysOffset;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Action action = Action.NONE;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Column(name =" number_in_order", nullable = false)
|
||||
private int numberInOrder = Integer.MAX_VALUE;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "checklist_template_id")
|
||||
private ChecklistTemplate checklistTemplate;
|
||||
|
||||
public ActivityTemplate() {
|
||||
|
|
|
@ -1004,17 +1004,46 @@ alter table `application_period_project_type` rename column `activityPlanTemplat
|
|||
|
||||
alter table `application_period_project_type` add primary key (application_period_id, project_type_id);
|
||||
|
||||
-- >>> STACK PUSH: 2nd table group: target, ActivityPlanTemplate and ActivityTemplate
|
||||
|
||||
-- table: ActivityTemplate, except foreign key to coming table activity_plan_template
|
||||
|
||||
alter table `ActivityTemplate` drop foreign key `FK_ca5bhq3i6p2g292fo5l4fqtf`;
|
||||
alter table `ActivityTemplate` drop foreign key `FK_activity_template_checklist_template`;
|
||||
alter table `ActivityTemplate` drop key `FKD4434665C5FC509F`;
|
||||
alter table `ActivityTemplate` drop key `FK_ca5bhq3i6p2g292fo5l4fqtf`;
|
||||
alter table `ActivityTemplate` drop key `FK_667ye6la0yb5obk64v21knimn`;
|
||||
|
||||
rename table `ActivityTemplate` to `activity_template`;
|
||||
|
||||
alter table `activity_template` rename column `numberInOrder` to `number_in_order`;
|
||||
alter table `activity_template` rename column `activityPlanTemplate_id` to `activity_plan_template_id`;
|
||||
alter table `activity_template` rename column `daysOffset` to `days_offset`;
|
||||
alter table `activity_template` rename column `checkListTemplate_id` to `checklist_template_id`;
|
||||
|
||||
alter table `activity_template`
|
||||
add constraint fk_activity_template_checklist_template_id
|
||||
foreign key (checklist_template_id) references checklist_template (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: ActivityPlanTemplate (at this stage, no any foreign key is are referenced to ActivityPlanTemplate)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Activate following later
|
||||
|
||||
-- **********************************************************************************
|
||||
-- TODO: fix table ActivityPlanTemplate, verify no foreign keys are referenced to ActivityPlanTemplate before fix it
|
||||
-- TODO: -- Add back all foreign key references to activity_plan_template
|
||||
-- **********************************************************************************
|
||||
|
||||
-- **********************************************************************************
|
||||
-- TODO: Add back all foreign key references to activity_plan_template
|
||||
-- **********************************************************************************
|
||||
-- add foreign key reference from activity_template to activity_plan_template
|
||||
alter table `activity_template`
|
||||
add constraint fk_activity_template_activity_plan_template_id
|
||||
foreign key (activity_plan_template_id) references activity_plan_template (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
|
||||
-- add foreign key reference from application_period_project_type to activity_plan_template
|
||||
alter table `application_period_project_type`
|
||||
|
@ -1030,7 +1059,7 @@ alter table `application_period_project_type`
|
|||
|
||||
|
||||
-- **********************************************************************************
|
||||
-- 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
|
||||
|
@ -1057,7 +1086,7 @@ 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
|
||||
|
@ -1157,6 +1186,11 @@ alter table `user_profile_project_type`
|
|||
where referenced_table_name is not null and table_name = 'user'
|
||||
order by table_name;
|
||||
|
||||
>>> Show foreign keys
|
||||
|
||||
select table_name, column_name, constraint_name, referenced_table_name, referenced_column_name
|
||||
from information_schema.key_column_usage
|
||||
where table_schema = 'tozh4728' and table_name = 'ActivityTemplate';
|
||||
|
||||
A. Drop FK from following tables
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user