Add MVP version
This commit is contained in:
159
apps/web/prisma/schema.prisma
Normal file
159
apps/web/prisma/schema.prisma
Normal file
@@ -0,0 +1,159 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
// NOTE: When using mysql or sqlserver, uncomment the @db.Text annotations in model Account below
|
||||
// Further reading:
|
||||
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
|
||||
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model AppSetting {
|
||||
key String @id
|
||||
value String
|
||||
}
|
||||
|
||||
// Necessary for Next auth
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId Int
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String
|
||||
refresh_token String? // @db.Text
|
||||
access_token String? // @db.Text
|
||||
refresh_token_expires_in Int?
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String? // @db.Text
|
||||
session_state String?
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique
|
||||
userId Int
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
name String?
|
||||
email String? @unique
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
teamUsers TeamUser[]
|
||||
}
|
||||
|
||||
model Team {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
teamUsers TeamUser[]
|
||||
domains Domain[]
|
||||
apiKeys ApiKey[]
|
||||
emails Email[]
|
||||
}
|
||||
|
||||
enum Role {
|
||||
ADMIN
|
||||
MEMBER
|
||||
}
|
||||
|
||||
model TeamUser {
|
||||
teamId Int
|
||||
userId Int
|
||||
role Role
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([teamId, userId])
|
||||
}
|
||||
|
||||
enum DomainStatus {
|
||||
NOT_STARTED
|
||||
PENDING
|
||||
SUCCESS
|
||||
FAILED
|
||||
TEMPORARY_FAILURE
|
||||
}
|
||||
|
||||
model Domain {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
teamId Int
|
||||
status DomainStatus @default(PENDING)
|
||||
region String @default("us-east-1")
|
||||
publicKey String
|
||||
dkimStatus String?
|
||||
spfDetails String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
enum ApiPermission {
|
||||
FULL
|
||||
SENDING
|
||||
}
|
||||
|
||||
model ApiKey {
|
||||
id Int @id @default(autoincrement())
|
||||
tokenHash String @unique
|
||||
partialToken String
|
||||
name String
|
||||
permission ApiPermission @default(SENDING)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
lastUsed DateTime?
|
||||
teamId Int
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model Email {
|
||||
id String @id
|
||||
to String
|
||||
from String
|
||||
subject String
|
||||
text String?
|
||||
html String?
|
||||
latestStatus String?
|
||||
teamId Int
|
||||
domainId Int?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
emailEvents EmailEvent[]
|
||||
}
|
||||
|
||||
model EmailEvent {
|
||||
emailId String
|
||||
status String
|
||||
data Json?
|
||||
createdAt DateTime @default(now())
|
||||
email Email @relation(fields: [emailId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([emailId, status])
|
||||
}
|
Reference in New Issue
Block a user