Files
ccn/Packages/Persistence/Sources/Internal/Migrations/AddShopRegistration.swift
T

31 lines
885 B
Swift

import FluentKit
/// Adds the seller kind and the business registration to shops.
///
/// Registered ahead of ``SeedCatalogue``, whose model writes the columns. One column per update: SQLite adds no more in a statement.
struct AddShopRegistration: AsyncMigration {
// MARK: Constants
private static let columns = ["kind", "kvk_number", "vat_id", "legal_name"]
// MARK: Methods
func prepare(on database: Database) async throws {
for column in Self.columns {
try await database.schema(ShopRecord.schema)
.field(.string(column), .string)
.update()
}
}
func revert(on database: Database) async throws {
for column in Self.columns.reversed() {
try await database.schema(ShopRecord.schema)
.deleteField(.string(column))
.update()
}
}
}