Add account API key management

This commit is contained in:
Mike Cao committed 2026-09-01 21:50:07 -07:00
1 parent 98b824ce48
commit f1c5b4f7bb
32 files changed
+1618 -15

No files matched your search

+16
View File
@@ -32,10 +32,26 @@ model User {
twoFactorBackupCodes TwoFactorBackupCode[]
twoFactorOtpUseds TwoFactorOtpUsed[]
twoFactorRateLimit TwoFactorRateLimit?
apiKeys ApiKey[]
@@map("user")
}
model ApiKey {
id String @id() @map("api_key_id") @db.Uuid
userId String @map("user_id") @db.Uuid
name String @db.VarChar(255)
keyHash String @unique @map("key_hash") @db.VarChar(128)
keyPrefix String @map("key_prefix") @db.VarChar(20)
lastUsedAt DateTime? @map("last_used_at") @db.Timestamptz(6)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@map("api_key")
}
model Session {
id String @id() @map("session_id") @db.Uuid
websiteId String @map("website_id") @db.Uuid