task/3382: Harmonisera tabellnamn #6
|
@ -1,11 +1,18 @@
|
|||
package se.su.dsv.scipro.system;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Table(name = "password")
|
||||
public class Password extends LazyDeletableDomainObject {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
package se.su.dsv.scipro.system;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
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.Table;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
|
@ -17,11 +24,10 @@ public class Unit extends DomainObject {
|
|||
@Column(unique = true)
|
||||
private Integer identifier;
|
||||
|
||||
@Column(length = STRING_MAX_LENGTH)
|
||||
@Basic(optional = false)
|
||||
@Column(nullable = false, length = STRING_MAX_LENGTH)
|
||||
private String title;
|
||||
|
||||
@Basic(optional = true)
|
||||
@Column(name = "match_responsible", nullable = true)
|
||||
private String matchResponsible;
|
||||
|
||||
public String getMatchResponsible() {
|
||||
|
|
|
@ -1,10 +1,32 @@
|
|||
package se.su.dsv.scipro.system;
|
||||
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Cacheable;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
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.JoinTable;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
@Entity
|
||||
@Table(name = "user")
|
||||
|
@ -18,9 +40,10 @@ public class User extends LazyDeletableDomainObject {
|
|||
@Column(unique = true)
|
||||
private Integer identifier;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(name = "first_name", nullable = false)
|
||||
private String firstName;
|
||||
@Basic(optional = false)
|
||||
|
||||
@Column(name = "last_name", nullable = false)
|
||||
private String lastName;
|
||||
|
||||
// Mapped to a generated column to allow sorting UserColumn in DataTables
|
||||
|
@ -35,14 +58,15 @@ public class User extends LazyDeletableDomainObject {
|
|||
// If you wish to test specific sort orders then add specific methods that sort
|
||||
// by firstName, lastName instead.
|
||||
@SuppressWarnings("unused")
|
||||
@Basic
|
||||
@Column(insertable = false, updatable = false)
|
||||
@Column(name = "full_name", insertable = false, updatable = false)
|
||||
private String fullName;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(name = "email_address", nullable = false)
|
||||
private String emailAddress;
|
||||
|
||||
@Basic(optional = false)
|
||||
private boolean deceased = false;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(name = "active_as_supervisor")
|
||||
private boolean activeAsSupervisor = false;
|
||||
|
@ -76,8 +100,8 @@ public class User extends LazyDeletableDomainObject {
|
|||
@OneToOne(optional = true)
|
||||
private Unit unit;
|
||||
|
||||
@Basic
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "degree_type")
|
||||
private DegreeType degreeType = ProjectType.UNKNOWN;
|
||||
|
||||
public Unit getUnit() {
|
||||
|
|
|
@ -619,9 +619,70 @@ alter table `user_language`
|
|||
foreign key (user_id) references user(id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: user, unit and password
|
||||
|
||||
alter table `user` drop foreign key `FK_hpmviec1b7vdg23xtxsalwxw8`;
|
||||
alter table `user` drop key `FK_hpmviec1b7vdg23xtxsalwxw8`;
|
||||
|
||||
alter table `user` drop foreign key `user_unit_id`;
|
||||
alter table `user` drop key `user_unit_id`;
|
||||
|
||||
alter table `user` drop key `identifier`;
|
||||
alter table `user` drop key `deleted_index`;
|
||||
|
||||
-- rename columns in table user
|
||||
|
||||
alter table `user` rename column `emailAddress` to `email_address`;
|
||||
alter table `user` rename column `firstName` to `first_name`;
|
||||
alter table `user` rename column `lastName` to `last_name`;
|
||||
alter table `user` rename column `fullName` to `full_name`;
|
||||
alter table `user` rename column `degreeType` to `degree_type`;
|
||||
|
||||
alter table `user` add constraint uk_user_identifier unique(identifier);
|
||||
create index idx_user_deleted on user(deleted);
|
||||
|
||||
-- fix table unit
|
||||
|
||||
alter table `unit` drop key `identifier`;
|
||||
|
||||
alter table `unit` rename column `matchResponsible` to `match_responsible`;
|
||||
|
||||
alter table `unit` add constraint uk_unit_identifier unique(identifier);
|
||||
|
||||
-- add FK from user to unit
|
||||
|
||||
alter table `user`
|
||||
add constraint fk_user_unit_id
|
||||
foreign key (unit_id) references unit(id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- fix table password
|
||||
|
||||
alter table `Password` drop foreign key `FK_43erxladp39q03wrco68hi9iq`;
|
||||
alter table `Password` drop key `FK_43erxladp39q03wrco68hi9iq`;
|
||||
alter table `Password` drop key `FK4C641EBB895349BF`;
|
||||
alter table `Password` drop key `deleted_index`;
|
||||
alter table `Password` drop key `UK_43erxladp39q03wrco68hi9iq`;
|
||||
alter table `Password` drop key `user_id`;
|
||||
|
||||
rename table `Password` to `password`;
|
||||
|
||||
alter table `password` add constraint uk_password_user_id unique(user_id);
|
||||
create index idx_password_deleted on password(deleted);
|
||||
|
||||
alter table `password`
|
||||
add constraint fk_password_user_id
|
||||
foreign key (user_id) references user(id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- add FK from user till password
|
||||
|
||||
alter table `user`
|
||||
add constraint fk_user_password_id
|
||||
foreign key (password_id) references password(id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
/* *********************************************************************************************** */
|
||||
|
||||
/* the mess with ProjectType
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user