I am trying to add a unique constraint on a column but it works if I recreate database but doesn't work when I update already existing database.
Similar with adding unique to index. Is there a reason why hibernate doesn't update column if database already exists? I am using Dropwizard.
@Entity
@Table(name = EnrollmentStatusEntity.TABLE_NAME,
indexes = {
@Index(name = Student_RollNo,
columnList = rollNo,
unique = true)
})
@Data
public class Student {
public static final String TABLE_NAME = "Student";
@Id
@NonNull
@Column(name = ID, unique = true, updatable = false, nullable = false)
private String id;
@NonNull
@Column(name = COMPARTMENT_ID, unique=true, nullable = false, updatable = false)
private String rollNo;