17 lines
549 B
Swift
17 lines
549 B
Swift
import Fluent
|
|
|
|
struct CreateSessions: AsyncMigration {
|
|
func prepare(on database: any Database) async throws {
|
|
try await database.schema("sessions")
|
|
.field("token", .string, .identifier(auto: false))
|
|
.field("type", .int, .required)
|
|
.field("expires", .datetime, .required)
|
|
.field("accountId", .int, .required, .references("accounts", "id"))
|
|
.create()
|
|
}
|
|
|
|
func revert(on database: any Database) async throws {
|
|
try await database.schema("sessions").delete()
|
|
}
|
|
}
|