diff --git a/Sources/pom.xml b/Sources/pom.xml index c569b14..af54282 100644 --- a/Sources/pom.xml +++ b/Sources/pom.xml @@ -47,6 +47,11 @@ ktorm-core 3.2.0 + + org.ktorm + ktorm-support-postgresql + 3.2.0 + ch.qos.logback logback-classic diff --git a/Sources/src/main/kotlin/allin/data/postgres/PostgresDataSource.kt b/Sources/src/main/kotlin/allin/data/postgres/PostgresDataSource.kt index bb89138..20794c2 100644 --- a/Sources/src/main/kotlin/allin/data/postgres/PostgresDataSource.kt +++ b/Sources/src/main/kotlin/allin/data/postgres/PostgresDataSource.kt @@ -36,6 +36,12 @@ class PostgresDataSource : AllInDataSource() { database.Execute( """ + CREATE TYPE bet.status AS ENUM + ('InProgress', 'Waiting', 'Closing', 'Finished', 'Cancelled'); + + CREATE TYPE bet.type AS ENUM + ('Match', 'Binary', 'Custom'); + CREATE TABLE IF not exists bet ( id uuid PRIMARY KEY, theme VARCHAR(255), @@ -44,8 +50,8 @@ class PostgresDataSource : AllInDataSource() { sentencebet varchar(500), isprivate boolean, createdby varchar(250), - status smallint, - type smallint + status bet.status, + type bet.type )""".trimIndent() ) diff --git a/Sources/src/main/kotlin/allin/entities/BetEntity.kt b/Sources/src/main/kotlin/allin/entities/BetEntity.kt index 1e8009d..0830ab8 100644 --- a/Sources/src/main/kotlin/allin/entities/BetEntity.kt +++ b/Sources/src/main/kotlin/allin/entities/BetEntity.kt @@ -4,6 +4,7 @@ import allin.model.BetStatus import allin.model.BetType import org.ktorm.entity.Entity import org.ktorm.schema.* +import org.ktorm.support.postgresql.pgEnum import java.time.ZonedDateTime @@ -25,7 +26,7 @@ object BetsEntity : Table("bet") { val endRegistration = timestamp("endregistration") val endBet = timestamp("endbet") val isPrivate = boolean("isprivate") - val status = enum("status") - val type = enum("type") + val status = pgEnum("status").bindTo { it.status } + val type = pgEnum("type").bindTo { it.type } val createdBy = varchar("createdby") } \ No newline at end of file