mirror of
https://github.com/penxio/penx.git
synced 2026-01-13 15:38:12 -05:00
275 lines
7.4 KiB
Plaintext
275 lines
7.4 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL") // uses connection pooling
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
enum AuthType {
|
|
GOOGLE
|
|
REOWN
|
|
RAINBOW_KIT
|
|
PRIVY
|
|
}
|
|
|
|
enum StorageProvider {
|
|
IPFS
|
|
R2
|
|
VERCEL_BLOB
|
|
SUPABASE_STORAGE
|
|
}
|
|
|
|
enum SiteMode {
|
|
BASIC
|
|
NOTE_TAKING
|
|
}
|
|
|
|
model Site {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
name String @db.VarChar(100)
|
|
description String @default("") @db.VarChar(500)
|
|
about String @default("") @db.Text
|
|
spaceId String? @db.VarChar(50)
|
|
logo String? @default("") @db.VarChar(2183)
|
|
font String @default("font-cal") @db.VarChar(50)
|
|
image String? @default("") @db.VarChar(2183)
|
|
email String? @unique @db.VarChar(255)
|
|
mode SiteMode @default(BASIC)
|
|
authSecret String? @unique @db.VarChar(255)
|
|
authType AuthType @default(RAINBOW_KIT)
|
|
authConfig Json?
|
|
storageProvider StorageProvider @default(IPFS)
|
|
storageConfig Json?
|
|
socials Json?
|
|
config Json?
|
|
themeName String? @db.VarChar(50)
|
|
themeConfig Json?
|
|
subdomain String? @unique @db.VarChar(255)
|
|
customDomain String? @unique @db.VarChar(255)
|
|
memberCount Int @default(0) @db.Integer
|
|
postCount Int @default(0) @db.Integer
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("site")
|
|
}
|
|
|
|
enum UserRole {
|
|
ADMIN
|
|
AUTHOR
|
|
READER
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
role UserRole @default(READER)
|
|
name String? @db.VarChar(255)
|
|
displayName String? @db.VarChar(255)
|
|
ensName String? @db.VarChar(255)
|
|
email String? @unique @db.VarChar(255)
|
|
emailVerified DateTime?
|
|
github Json? // github oauth info
|
|
google Json? // google oauth info
|
|
image String? @db.VarChar(2183)
|
|
cover String? @db.VarChar(2183)
|
|
bio String @default("") @db.VarChar(5000)
|
|
about String @default("")
|
|
subscriptions Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
posts Post[]
|
|
comments Comment[]
|
|
tags Tag[]
|
|
accessTokens AccessToken[]
|
|
accounts Account[]
|
|
|
|
@@index([id])
|
|
@@map("user")
|
|
}
|
|
|
|
enum ProviderType {
|
|
GOOGLE
|
|
GITHUB
|
|
WALLET
|
|
FARCASTER
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
providerType ProviderType
|
|
providerAccountId String @unique @default("") @db.VarChar(255)
|
|
providerInfo Json?
|
|
refreshToken String? @db.VarChar(255)
|
|
accessToken String? @db.VarChar(255)
|
|
expiresAt Int?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
user User @relation(fields: [userId], references: [id])
|
|
userId String @db.Uuid
|
|
|
|
@@index([userId])
|
|
@@map("account")
|
|
}
|
|
|
|
model Node {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
userId String?
|
|
parentId String?
|
|
databaseId String?
|
|
type String
|
|
element Json?
|
|
props Json?
|
|
collapsed Boolean @default(false)
|
|
folded Boolean @default(true)
|
|
children Json?
|
|
date String? @db.VarChar(20)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([userId])
|
|
@@index([type])
|
|
@@map("node")
|
|
}
|
|
|
|
enum PostType {
|
|
ARTICLE
|
|
IMAGE
|
|
VIDEO
|
|
AUDIO
|
|
NFT
|
|
FIGMA
|
|
NOTE
|
|
}
|
|
|
|
enum GateType {
|
|
FREE
|
|
PAID
|
|
MEMBER_ONLY
|
|
}
|
|
|
|
enum PostStatus {
|
|
PUBLISHED
|
|
DRAFT
|
|
ARCHIVED
|
|
}
|
|
|
|
enum CommentStatus {
|
|
OPEN
|
|
CLOSED
|
|
}
|
|
|
|
model Post {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
slug String @unique @default(uuid())
|
|
title String @default("") @db.VarChar(500)
|
|
description String @default("") @db.VarChar(1000)
|
|
content String @default("") @db.Text
|
|
cid String @default("") @db.VarChar(100)
|
|
nodeId String? @unique @db.Uuid
|
|
creationId Int? @db.Integer
|
|
type PostType @default(ARTICLE)
|
|
gateType GateType @default(FREE)
|
|
postStatus PostStatus @default(DRAFT)
|
|
commentStatus CommentStatus @default(OPEN)
|
|
commentCount Int @default(0) @db.Integer
|
|
image String? @default("") @db.VarChar(2183)
|
|
featured Boolean @default(false)
|
|
collectible Boolean @default(false)
|
|
publishedAt DateTime?
|
|
archivedAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
user User @relation(fields: [userId], references: [id])
|
|
userId String @db.Uuid
|
|
comments Comment[]
|
|
postTags PostTag[]
|
|
|
|
@@index([userId])
|
|
@@index([postStatus])
|
|
@@index([type])
|
|
@@index([gateType])
|
|
@@index([userId, postStatus])
|
|
@@index([userId, type])
|
|
@@map("post")
|
|
}
|
|
|
|
model Comment {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
content String @default("") @db.Text
|
|
// Points to the ID of the parent comment, null for the root comment
|
|
parentId String? @db.Uuid
|
|
replyCount Int @default(0) @db.Integer
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
post Post @relation(fields: [postId], references: [id])
|
|
postId String @db.Uuid
|
|
user User @relation(fields: [userId], references: [id])
|
|
userId String @db.Uuid
|
|
parent Comment? @relation("ReplyRelation", fields: [parentId], references: [id]) // parent comments
|
|
replies Comment[] @relation("ReplyRelation") // sub comments
|
|
|
|
@@index([postId])
|
|
@@index([userId])
|
|
@@map("comment")
|
|
}
|
|
|
|
model Tag {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
name String @default("") @db.VarChar(50)
|
|
color String @default("") @db.VarChar(50)
|
|
postCount Int @default(0) @db.Integer
|
|
hidden Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
User User? @relation(fields: [userId], references: [id])
|
|
userId String? @db.Uuid
|
|
postTags PostTag[]
|
|
|
|
@@index(name)
|
|
@@index(hidden)
|
|
@@map("tag")
|
|
}
|
|
|
|
model PostTag {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
post Post @relation(fields: [postId], references: [id])
|
|
postId String @db.Uuid
|
|
tag Tag @relation(fields: [tagId], references: [id])
|
|
tagId String @db.Uuid
|
|
|
|
@@index([postId])
|
|
@@map("post_tag")
|
|
}
|
|
|
|
model Asset {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
url String @default("") @db.VarChar(2183)
|
|
cid String @default("") @db.VarChar(100)
|
|
type String? @db.VarChar(20)
|
|
|
|
@@map("asset")
|
|
}
|
|
|
|
model AccessToken {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
token String @default("") @db.VarChar(255)
|
|
alias String? @db.VarChar(50)
|
|
expiredAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
lastUsedAt DateTime?
|
|
user User @relation(fields: [userId], references: [id])
|
|
userId String @db.Uuid
|
|
|
|
@@index([userId])
|
|
@@map("access_token")
|
|
}
|