Migrated the Service method in the Persistence package to use PostgreSQL instead.

This commit is contained in:
2026-08-04 17:44:02 +02:00
parent d7d2709f88
commit 1fe7ef2049
2 changed files with 30 additions and 29 deletions
@@ -1,4 +1,4 @@
import FluentMySQLDriver
import FluentPostgresDriver
import FluentSQLiteDriver
import HummingbirdFluent
import Logging
@@ -37,27 +37,28 @@ public struct Service: Sendable {
/// The selected backend is registered as the *default* database, so repositories resolve it with a plain `fluent.db()` and stay agnostic of which
/// driver is in use. The returned service is not yet running; add it to the application's service group (`app.addServices(_:)`) so it starts and shuts
/// its connection pool down alongside the server.
/// - Throws: an error when the TLS context for the PostgreSQL backend cannot be built.
/// - Returns: the configured `Fluent` service, ready to be added to the service group.
public func callAsFunction() -> Fluent {
public func callAsFunction() throws -> Fluent {
let fluent = Fluent(
logger: logger
)
switch driver {
case .mysql(let configuration):
case .postgres(let configuration):
fluent.databases.use(
.mysql(
.postgres(
configuration: .init(
hostname: configuration.host,
port: configuration.port,
username: configuration.username,
password: configuration.password,
database: configuration.name,
tlsConfiguration: configuration.tls.tlsConfiguration
tls: try configuration.tls.postgresTLS()
),
maxConnectionsPerEventLoop: configuration.maxConnectionsPerEventLoop
),
as: .mysql,
as: .psql,
isDefault: true
)
case .inMemory: