Move sessions to db table instead of JWTs
This commit is contained in:
16
Sources/stella/Migrations/CreateSessions.swift
Normal file
16
Sources/stella/Migrations/CreateSessions.swift
Normal file
@@ -0,0 +1,16 @@
|
||||
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()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user