From 198709dc29afc2e365849337739dc309915b4f4a Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Fri, 27 Sep 2024 20:40:48 -0500 Subject: [PATCH] Take advantage of the fact that the enum is CaseIterable for Postgres as well as MySQL --- Sources/QueuesFluentDriver/JobModelMigrate.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/QueuesFluentDriver/JobModelMigrate.swift b/Sources/QueuesFluentDriver/JobModelMigrate.swift index ab5a2e0..02714bd 100644 --- a/Sources/QueuesFluentDriver/JobModelMigrate.swift +++ b/Sources/QueuesFluentDriver/JobModelMigrate.swift @@ -25,11 +25,11 @@ public struct JobModelMigration: AsyncSQLMigration { switch database.dialect.enumSyntax { case .typeName: stateEnumType = "\(self.jobsTableString)_storedjobstatus" - try await database.create(enum: stateEnumType) - .value("pending") - .value("processing") - .value("completed") - .run() + var builder = database.create(enum: stateEnumType) + for `case` in StoredJobState.allCases { + builder = builder.value(`case`.rawValue) + } + try await builder.run() case .inline: stateEnumType = "enum('\(StoredJobState.allCases.map(\.rawValue).joined(separator: "','"))')" default: