Skip to content

Commit

Permalink
Take advantage of the fact that the enum is CaseIterable for Postgres…
Browse files Browse the repository at this point in the history
… as well as MySQL
  • Loading branch information
gwynne committed Sep 28, 2024
1 parent 8f4ee7e commit 198709d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/QueuesFluentDriver/JobModelMigrate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 198709d

Please sign in to comment.