Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

update the db schema

Kiran Kd6c0e872e957
diff --git a/apps/web/prisma/schema.prisma b/apps/web/prisma/schema.prisma
index 45ac2dffd0..7b2faa276a 100644
--- a/apps/web/prisma/schema.prisma
+++ b/apps/web/prisma/schema.prisma
@@ -90,21 +90,23 @@ model Token {
}
model RestrictedToken {
- id String @id @default(cuid())
- name String
- hashedKey String @unique
- partialKey String
- scopes String? // space separated (Eg: "read:links write:links")
- expires DateTime?
- lastUsed DateTime?
- rateLimit Int @default(600) // rate limit per minute
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
- userId String
- projectId String
+ id String @id @default(cuid())
+ name String
+ hashedKey String @unique
+ partialKey String
+ scopes String? // space separated (Eg: "read:links write:links")
+ expires DateTime?
+ lastUsed DateTime?
+ rateLimit Int @default(600) // rate limit per minute
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ userId String
+ projectId String
+ oAuthClientId String? // if the token is generated by an OAuth client (access token)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
+ oAuthClient OAuthClient? @relation(fields: [oAuthClientId], references: [id], onDelete: Cascade)
refreshTokens OAuthRefreshToken[]
@@index([userId])
@@ -146,7 +148,7 @@ model Project {
customers Customer[]
defaultDomains DefaultDomains[]
restrictedTokens RestrictedToken[]
- apps OAuthApp[]
+ oAuthClients OAuthClient[]
@@index(usageLastChecked(sort: Asc))
}
@@ -357,35 +359,7 @@ model Customer {
@@index(externalId)
}
-model jackson_index {
- id Int @id @default(autoincrement())
- key String @db.VarChar(250)
- storeKey String @db.VarChar(250)
-
- @@index([key], map: "_jackson_index_key")
- @@index([key, storeKey], map: "_jackson_index_key_store")
-}
-
-model jackson_store {
- key String @id @db.VarChar(250)
- value String @db.Text
- iv String? @db.VarChar(64)
- tag String? @db.VarChar(64)
- namespace String? @db.VarChar(64)
- createdAt DateTime @default(now()) @db.Timestamp(0)
- modifiedAt DateTime? @db.Timestamp(0)
-
- @@index([namespace], map: "_jackson_store_namespace")
-}
-
-model jackson_ttl {
- key String @id @db.VarChar(250)
- expiresAt BigInt
-
- @@index([expiresAt], map: "_jackson_ttl_expires_at")
-}
-
-model OAuthApp {
+model OAuthClient {
id String @id @default(cuid())
projectId String
name String
@@ -399,36 +373,65 @@ model OAuthApp {
updatedAt DateTime @updatedAt
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
- codes OAuthCode[]
+ accessCodes OAuthCode[]
+ accessTokens RestrictedToken[]
refreshTokens OAuthRefreshToken[]
@@index(projectId)
}
model OAuthCode {
- id String @id @default(cuid())
- clientId String
- userId String // User who granted access
- projectId String // Workspace that user granted access to
- code String @unique
- scopes String?
- redirectUri String
- expiresAt DateTime
- createdAt DateTime @default(now())
-
- app OAuthApp @relation(fields: [clientId], references: [clientId], onDelete: Cascade)
+ id String @id @default(cuid())
+ oAuthClientId String
+ userId String // User who granted access
+ projectId String // Workspace that user granted access to
+ code String @unique
+ scopes String?
+ redirectUri String
+ expiresAt DateTime
+ createdAt DateTime @default(now())
+
+ oAuthClient OAuthClient @relation(fields: [oAuthClientId], references: [clientId], onDelete: Cascade)
}
model OAuthRefreshToken {
id String @id @default(cuid())
- clientId String
+ oAuthClientId String
accessTokenId String
refreshTokenHashed String @unique
expiresAt DateTime
createdAt DateTime @default(now())
+ oAuthClient OAuthClient @relation(fields: [oAuthClientId], references: [clientId], onDelete: Cascade)
accessToken RestrictedToken @relation(fields: [accessTokenId], references: [id], onDelete: Cascade)
- app OAuthApp @relation(fields: [clientId], references: [clientId], onDelete: Cascade)
@@index(accessTokenId)
}
+
+model jackson_index {
+ id Int @id @default(autoincrement())
+ key String @db.VarChar(250)
+ storeKey String @db.VarChar(250)
+
+ @@index([key], map: "_jackson_index_key")
+ @@index([key, storeKey], map: "_jackson_index_key_store")
+}
+
+model jackson_store {
+ key String @id @db.VarChar(250)
+ value String @db.Text
+ iv String? @db.VarChar(64)
+ tag String? @db.VarChar(64)
+ namespace String? @db.VarChar(64)
+ createdAt DateTime @default(now()) @db.Timestamp(0)
+ modifiedAt DateTime? @db.Timestamp(0)
+
+ @@index([namespace], map: "_jackson_store_namespace")
+}
+
+model jackson_ttl {
+ key String @id @db.VarChar(250)
+ expiresAt BigInt
+
+ @@index([expiresAt], map: "_jackson_ttl_expires_at")
+}