Use unique index rather than constraint when using formula [like lower(column)]

This commit is contained in:
rob bygrave
2020-01-15 16:58:55 +13:00
parent 099adcf6cd
commit bb56725b12
14 changed files with 84 additions and 39 deletions
@@ -9,10 +9,10 @@ import javax.persistence.Table;
import static io.ebean.annotation.Platform.MYSQL;
import static io.ebean.annotation.Platform.POSTGRES;
@Index(name = "ix_m12_otoc71", columnNames = "foo(name)", platforms = {POSTGRES})
@Index(name = "ix_m12_otoc72", columnNames = "bar(name)", platforms = {MYSQL})
@Index(unique = true, name = "uq_m12_otoc71", columnNames = "uqFoo(name)", platforms = {POSTGRES})
@Index(unique = true, name = "uq_m12_otoc72", columnNames = "uqBar(name)", platforms = {MYSQL})
@Index(name = "ix_m12_otoc71", columnNames = "name", platforms = {POSTGRES})
@Index(name = "ix_m12_otoc72", columnNames = "name", platforms = {MYSQL})
@Index(unique = true, name = "uq_m12_otoc71", columnNames = "lower(name)", platforms = {POSTGRES})
@Index(unique = true, name = "uq_m12_otoc72", columnNames = "name", platforms = {MYSQL})
@Index(columnNames = "name", platforms = POSTGRES)
@Entity
@Table(name = "migtest_oto_child")
@@ -9,10 +9,9 @@ import javax.persistence.Table;
import static io.ebean.annotation.Platform.MYSQL;
import static io.ebean.annotation.Platform.POSTGRES;
@Index(columnNames = "foo(name)", platforms = {POSTGRES})
@Index(columnNames = "bar(name)", platforms = {MYSQL})
@Index(unique = true, columnNames = "foo(name)", platforms = {POSTGRES})
@Index(unique = true, columnNames = "bar(name)", platforms = {MYSQL})
@Index(columnNames = "name", platforms = {MYSQL})
@Index(unique = true, columnNames = "lower(name)", platforms = {POSTGRES})
@Index(unique = true, columnNames = "name", platforms = {MYSQL})
@Entity
@Table(name = "migtest_oto_master")
public class OtoMaster {