Files
ccn/Packages/Persistence/Sources/Public/Methods/PrepareDB.swift
T

30 lines
1002 B
Swift
Raw Normal View History

import HummingbirdFluent
/// A registrar declaring every migration against a `Fluent` service.
///
/// Built once around the application's `Fluent` service and called as a function — `await migrate()` —
/// during startup, before the migrations are applied.
public struct PrepareDB {
// MARK: Initializers
/// Creates a registrar for the migrations for a `Fluent` service.
public init() {}
// MARK: Methods
/// Registers every migration against the `Fluent` service, in order.
///
/// This is the single place migrations are declared: add each new migration here, in the order it must
/// run (migrations are applied in registration order and are append-only). Registering does not apply
/// them — the caller runs `fluent.migrate()` (or the executable's migrate-and-exit mode) to do that.
public func callAsFunction(
for fluent: Fluent
) async {
await fluent.migrations.add([
CreateExampleRecord()
])
}
}