From fc9449de60ef1d93ce3d17b87e8b8fa1482b2521 Mon Sep 17 00:00:00 2001 From: "arthur.valin" Date: Tue, 6 Feb 2024 16:44:25 +0100 Subject: [PATCH] try fix pg enums --- .../allin/data/postgres/PostgresDataSource.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Sources/src/main/kotlin/allin/data/postgres/PostgresDataSource.kt b/Sources/src/main/kotlin/allin/data/postgres/PostgresDataSource.kt index 5fbe6f7..b791574 100644 --- a/Sources/src/main/kotlin/allin/data/postgres/PostgresDataSource.kt +++ b/Sources/src/main/kotlin/allin/data/postgres/PostgresDataSource.kt @@ -38,12 +38,18 @@ class PostgresDataSource : AllInDataSource() { database.Execute( """ - CREATE TYPE IF not exists betstatus AS ENUM - ('InProgress', 'Waiting', 'Closing', 'Finished', 'Cancelled'); - - CREATE TYPE IF not exists bettype AS ENUM - ('Match', 'Binary', 'Custom'); - + DO ${'$'}${'$'} + BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'betstatus') THEN + CREATE TYPE IF not exists betstatus AS ENUM + ('InProgress', 'Waiting', 'Closing', 'Finished', 'Cancelled'); + END IF; + IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'bettype') THEN + CREATE TYPE IF not exists bettype AS ENUM + ('Match', 'Binary', 'Custom'); + END IF; + END${'$'}${'$'}; + CREATE TABLE IF not exists bet ( id uuid PRIMARY KEY, theme VARCHAR(255),