Added the catalogue models and seed to support phase 5 of the POC prototype in the Persistence package.
This commit is contained in:
1 parent
9403931109
commit
89a7a7b8e5
19 files changed
+990
-15
No files matched your search
@@ -0,0 +1,30 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user