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,41 @@
|
||||
import FluentKit
|
||||
|
||||
/// Creates the `wants` table, and the `series` table seeded with the runs the demo listings belong to.
|
||||
struct CreateCollecting: AsyncMigration {
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
func prepare(on database: Database) async throws {
|
||||
try await database.schema(WantRecord.schema)
|
||||
.id()
|
||||
.field("user_id", .uuid, .required, .references(UserRecord.schema, "id", onDelete: .cascade))
|
||||
.field("title", .string, .required)
|
||||
.field("min_grade", .double)
|
||||
.field("max_price_cents", .int)
|
||||
.field("slabbed_only", .bool, .required)
|
||||
.field("alerts", .bool, .required)
|
||||
.field("created_at", .datetime, .required)
|
||||
.field("seen_at", .datetime, .required)
|
||||
.create()
|
||||
try await database.schema(SeriesRecord.schema)
|
||||
.id()
|
||||
.field("slug", .string, .required)
|
||||
.field("name", .string, .required)
|
||||
.field("publisher", .string, .required)
|
||||
.field("years", .string, .required)
|
||||
.field("issue_count", .int, .required)
|
||||
.field("blurb", .string, .required)
|
||||
.unique(on: "slug")
|
||||
.create()
|
||||
|
||||
for series in Seed.series {
|
||||
try await SeriesRecord(series).save(on: database)
|
||||
}
|
||||
}
|
||||
|
||||
func revert(on database: Database) async throws {
|
||||
try await database.schema(SeriesRecord.schema).delete()
|
||||
try await database.schema(WantRecord.schema).delete()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user