task/3382: Harmonisera tabellnamn #6
@ -1,17 +1,26 @@
|
|||||||
package se.su.dsv.scipro.system;
|
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.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.persistence.UniqueConstraint;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@Table(name="username", uniqueConstraints={@UniqueConstraint(name = "uk_username", columnNames={"username"})})
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
@Table(name="user_name", uniqueConstraints={@UniqueConstraint(name = "uk_user_name", columnNames={"user_name"})})
|
|
||||||
public class Username extends DomainObject {
|
public class Username extends DomainObject {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(name = "user_name", nullable = false)
|
@Column(name = "username", nullable = false)
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@ManyToOne(optional=false)
|
@ManyToOne(optional=false)
|
||||||
|
@ -587,14 +587,10 @@ alter table `username` drop foreign key `FK_17moq4bksxe30ihucce3jovdc`;
|
|||||||
alter table `username` drop key `FK_17moq4bksxe30ihucce3jovdc`;
|
alter table `username` drop key `FK_17moq4bksxe30ihucce3jovdc`;
|
||||||
alter table `username` drop key `username_must_be_unique`;
|
alter table `username` drop key `username_must_be_unique`;
|
||||||
|
|
||||||
rename table `username` to `user_name`;
|
alter table `username` add constraint uk_username unique(username);
|
||||||
|
|
||||||
alter table `user_name` rename column `username` to `user_name`;
|
alter table `username`
|
||||||
|
add constraint fk_username_user_id
|
||||||
alter table `user_name` add constraint uk_user_name unique(user_name);
|
|
||||||
|
|
||||||
alter table `user_name`
|
|
||||||
add constraint fk_user_name_user_id
|
|
||||||
foreign key (user_id) references user (id)
|
foreign key (user_id) references user (id)
|
||||||
on delete cascade on update cascade;
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user