Added the catalogue models and seed to support phase 4 of the POC prototype in the Persistence package.
This commit is contained in:
1 parent
0dc3fe6bea
commit
95e0a455e8
14 files changed
+743
-9
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import FluentKit
|
||||
|
||||
/// Adds the declared defects and the photos to listings.
|
||||
///
|
||||
/// Registered ahead of ``SeedCatalogue``, whose model writes both columns.
|
||||
struct AddListingDeclarations: AsyncMigration {
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
func prepare(on database: Database) async throws {
|
||||
// One column per update: SQLite adds no more in a single statement.
|
||||
try await database.schema(ListingRecord.schema)
|
||||
.field("defects", .string)
|
||||
.update()
|
||||
try await database.schema(ListingRecord.schema)
|
||||
.field("photos", .string)
|
||||
.update()
|
||||
}
|
||||
|
||||
func revert(on database: Database) async throws {
|
||||
try await database.schema(ListingRecord.schema)
|
||||
.deleteField("photos")
|
||||
.update()
|
||||
try await database.schema(ListingRecord.schema)
|
||||
.deleteField("defects")
|
||||
.update()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import FluentKit
|
||||
|
||||
/// Creates and drops the `passkeys` table backing ``PasskeyRecord``.
|
||||
struct CreatePasskey: AsyncMigration {
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
func prepare(on database: Database) async throws {
|
||||
try await database.schema(PasskeyRecord.schema)
|
||||
.id()
|
||||
.field("user_id", .uuid, .required, .references(UserRecord.schema, "id", onDelete: .cascade))
|
||||
.field("credential_id", .string, .required)
|
||||
.field("public_key", .string, .required)
|
||||
.field("sign_count", .int, .required)
|
||||
.field("created_at", .datetime, .required)
|
||||
.unique(on: "credential_id")
|
||||
.create()
|
||||
}
|
||||
|
||||
func revert(on database: Database) async throws {
|
||||
try await database.schema(PasskeyRecord.schema)
|
||||
.delete()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user