task/3382: Harmonisera tabellnamn #6
|
@ -1,12 +1,30 @@
|
|||
package se.su.dsv.scipro.checklist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.Lob;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
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.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "checklist_template")
|
||||
public class ChecklistTemplate extends DomainObject {
|
||||
|
@ -23,20 +41,24 @@ public class ChecklistTemplate extends DomainObject {
|
|||
@Basic(optional = true)
|
||||
private String description;
|
||||
|
||||
@Column
|
||||
@Column(name = "template_number")
|
||||
private int templateNumber = DEFAULT_TEMPLATE_NUMBER;
|
||||
|
||||
@Lob
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "checklist_template_question",
|
||||
joinColumns = @JoinColumn(name = "checklist_template_id"))
|
||||
@Column(name = "question")
|
||||
private List<String> questions = new ArrayList<>(1);
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
tozh4728 marked this conversation as resolved
Outdated
|
||||
@JoinColumn(name = "user_id")
|
||||
private User creator;
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
joinColumns = @JoinColumn(name = "checklist_template_id")
|
||||
)
|
||||
@JoinTable(name = "checklist_template_checklist_category",
|
||||
joinColumns = @JoinColumn(name = "checklist_template_id", referencedColumnName = "id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "checklist_category_id", referencedColumnName = "id"))
|
||||
private List<ChecklistCategory> categories = new ArrayList<>();
|
||||
|
||||
@ManyToMany
|
||||
|
|
|
@ -1348,6 +1348,53 @@ alter table `checklist_answer`
|
|||
|
||||
alter table `checklist_question` rename column `questionNumber` to `question_number`;
|
||||
|
||||
-- table: ChecklistTemplate_questions
|
||||
|
||||
alter table `ChecklistTemplate_questions` drop foreign key `FK872F7C0E869F0235`;
|
||||
alter table `ChecklistTemplate_questions` drop key `FK872F7C0E869F0235`;
|
||||
|
||||
rename table `ChecklistTemplate_questions` to `checklist_template_question`;
|
||||
|
||||
alter table `checklist_template_question` rename column `CheckListTemplate_id` to `checklist_template_id`;
|
||||
alter table `checklist_template_question` rename column `questions` to `question`;
|
||||
|
||||
alter table `checklist_template_question`
|
||||
add constraint fk_ctq_checklist_template_id
|
||||
foreign key (checklist_template_id) references checklist_template (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: checklist_template_checklist_category
|
||||
|
||||
alter table `checklist_template_checklist_category` drop foreign key `FK4E82F4438725F1D`;
|
||||
alter table `checklist_template_checklist_category` drop foreign key `FK4E82F44372B51E82`;
|
||||
alter table `checklist_template_checklist_category` drop key `FK4E82F4438725F1D`;
|
||||
alter table `checklist_template_checklist_category` drop key `FK4E82F44372B51E82`;
|
||||
|
||||
alter table `checklist_template_checklist_category` rename column `categories_id` to `checklist_category_id`;
|
||||
|
||||
alter table `checklist_template_checklist_category`
|
||||
add constraint fk_ct_cc_checklist_template_id
|
||||
foreign key (checklist_template_id) references checklist_template (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `checklist_template_checklist_category`
|
||||
add constraint fk_ct_cc_checklist_category_id
|
||||
foreign key (checklist_category_id) references checklist_category (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: checklist_template
|
||||
|
||||
alter table `checklist_template` drop foreign key `FK14DA6F3E44F4DBE`;
|
||||
alter table `checklist_template` drop key `FK14DA6F3E44F4DBE`;
|
||||
|
||||
alter table `checklist_template` rename column `creator_id` to `user_id`;
|
||||
alter table `checklist_template` rename column `templateNumber` to `template_number`;
|
||||
|
||||
alter table `checklist_template`
|
||||
add constraint fk_checklist_template_user_id
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user
Less self describing column name.
creator_id
tells you it is the user who created the template rather than just a genericuser_id
. The referenced table/type is visible from the foreign key/class.