33 lines
1.1 KiB
Swift
33 lines
1.1 KiB
Swift
import FluentKit
|
|||
|
|
|
||
|
|
/// Creates and drops the `shops` table backing ``ShopRecord``.
|
||
|
|
struct CreateShop: AsyncMigration {
|
||
|
|
|
||
|
|
// MARK: Methods
|
||
|
|
|
||
|
|
func prepare(on database: Database) async throws {
|
||
|
|
try await database.schema(ShopRecord.schema)
|
||
|
|
.id()
|
||
|
|
.field("slug", .string, .required)
|
||
|
|
.field("name", .string, .required)
|
||
|
|
.field("city", .string, .required)
|
||
|
|
.field("country", .string, .required)
|
||
|
|
.field("since_year", .int, .required)
|
||
|
|
.field("is_verified", .bool, .required)
|
||
|
|
.field("rating", .double, .required)
|
||
|
|
.field("rated_sales", .int, .required)
|
||
|
|
.field("sold_count", .int, .required)
|
||
|
|
.field("handling_days", .int, .required)
|
||
|
|
.field("ships_note", .string, .required)
|
||
|
|
.field("returns_note", .string, .required)
|
||
|
|
.field("about", .string, .required)
|
||
|
|
.unique(on: "slug")
|
||
|
|
.create()
|
||
|
|
}
|
||
|
|
|
||
|
|
func revert(on database: Database) async throws {
|
||
|
|
try await database.schema(ShopRecord.schema)
|
||
|
|
.delete()
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|