feat: add ApiKey model for new Api auth, owned by a user

pull/2374/head
Agusti Fernandez Pardo 2022-03-25 15:56:30 +01:00
parent 3341074bb2
commit 76f951d76f
1 changed files with 10 additions and 0 deletions

View File

@ -150,6 +150,7 @@ model User {
metadata Json?
verified Boolean? @default(false)
ApiKey ApiKey[]
@@map(name: "users")
}
@ -363,3 +364,12 @@ model Webhook {
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
eventType EventType? @relation(fields: [eventTypeId], references: [id], onDelete: Cascade)
}
model ApiKey {
id String @id @unique @default(cuid())
userId Int?
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
expiresAt DateTime @default(dbgenerated("NOW() + interval '30 day'"))
metadata Json?
}