task/3382: Partially fix table idea

Remove foreign key from table idea to table ProjectType, rename the foreign key column at idea.
Change JPA-metadata in Idea entity class as well.
This commit is contained in:
Tom Zhao 2024-07-05 10:00:36 +02:00
parent f750dad22c
commit 237d15351e
2 changed files with 16 additions and 0 deletions
core/src/main
java/se/su/dsv/scipro/match
resources/db/migration

@ -23,6 +23,7 @@ public class Idea extends DomainObject {
private Long id;
@ManyToOne(optional = false)
@JoinColumn(name = "project_type_id")
private ProjectType projectType;
@Enumerated(EnumType.STRING)

@ -910,6 +910,15 @@ alter table `milestone_activity_template_project_type`
foreign key (milestone_activity_template_id) references milestone_activity_template(id)
on delete cascade on update cascade;
-- table: idea, we only remove foreign key from idea to ProjectType and rename the column projectType_id here.
-- This table has many related tables and will be fixed later.
alter table `idea` drop foreign key `FK_idea_projectType`;
alter table `idea` drop key `FK_idea_projectType`;
alter table `idea` rename column `projectType_id` to `project_type_id`;
/* Activate following later
@ -919,6 +928,12 @@ alter table `milestone_activity_template_project_type`
-- Add back all foreign key references to project_typ
-- add foreign key reference from idea to project_type
alter table `idea`
add constraint fk_idea_project_type_id
foreign key (project_type_id) references project_type(id)
on delete cascade on update cascade;
-- add foreign key reference from milestone_activity_template_project_type to project_type
alter table `milestone_activity_template_project_type`
add constraint fk_ma_tpt_project_type_id