stacker.news/prisma/schema.prisma

433 lines
12 KiB
Plaintext
Raw Normal View History

2021-03-25 19:29:24 +00:00
// 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")
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
name String? @unique @db.Citext
email String? @unique
emailVerified DateTime? @map(name: "email_verified")
image String?
items Item[] @relation("UserItems")
fwdItems Item[] @relation("FwdItem")
mentions Mention[]
messages Message[]
actions ItemAct[]
invoices Invoice[]
withdrawls Withdrawl[]
invites Invite[] @relation(name: "Invites")
invite Invite? @relation(fields: [inviteId], references: [id])
inviteId String?
bio Item? @relation(fields: [bioId], references: [id])
bioId Int?
msats Int @default(0)
stackedMsats Int @default(0)
2022-09-27 21:19:15 +00:00
freeComments Int @default(5)
freePosts Int @default(2)
checkedNotesAt DateTime?
tipDefault Int @default(10)
fiatCurrency String @default("USD")
pubkey String? @unique
trust Float @default(0)
2022-06-27 20:49:52 +00:00
upvoteTrust Float @default(0)
lastSeenAt DateTime?
lastCheckedJobs DateTime?
2022-05-16 20:51:22 +00:00
photoId Int?
photo Upload? @relation(fields: [photoId], references: [id])
2021-03-25 19:29:24 +00:00
2021-12-09 20:40:40 +00:00
upvotePopover Boolean @default(false)
tipPopover Boolean @default(false)
2022-04-21 22:50:02 +00:00
// notification settings
noteItemSats Boolean @default(true)
noteEarning Boolean @default(true)
noteAllDescendants Boolean @default(true)
noteMentions Boolean @default(true)
noteDeposits Boolean @default(true)
noteInvites Boolean @default(true)
noteJobIndicator Boolean @default(true)
2022-04-21 22:50:02 +00:00
2022-08-30 21:50:47 +00:00
// privacy settings
hideInvoiceDesc Boolean @default(false)
2022-09-21 19:57:36 +00:00
// content settings
wildWestMode Boolean @default(false)
2022-09-27 21:19:15 +00:00
greeterMode Boolean @default(false)
2022-09-21 19:57:36 +00:00
2022-07-30 13:25:46 +00:00
Earn Earn[]
Upload Upload[] @relation(name: "Uploads")
PollVote PollVote[]
2022-08-06 22:03:57 +00:00
2021-10-06 14:43:32 +00:00
@@index([createdAt])
2022-03-10 19:26:35 +00:00
@@index([inviteId])
2021-03-25 19:29:24 +00:00
@@map(name: "users")
}
2022-05-12 18:44:21 +00:00
model Upload {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
type String
size Int
width Int?
height Int?
item Item? @relation(fields: [itemId], references: [id])
2022-07-21 22:55:05 +00:00
itemId Int? @unique
2022-05-16 20:51:22 +00:00
user User @relation(name: "Uploads", fields: [userId], references: [id])
2022-05-12 18:44:21 +00:00
userId Int
2022-05-16 20:51:22 +00:00
User User[]
2022-08-06 22:03:57 +00:00
2022-05-12 18:44:21 +00:00
@@index([createdAt])
@@index([itemId])
@@index([userId])
}
enum EarnType {
POST
COMMENT
TIP_COMMENT
TIP_POST
}
2022-03-17 20:13:19 +00:00
model Earn {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
msats Int
user User @relation(fields: [userId], references: [id])
userId Int
type EarnType?
typeId Int?
rank Int?
2022-03-17 20:13:19 +00:00
@@index([createdAt])
@@index([userId])
@@index([createdAt, userId])
2022-03-17 20:13:19 +00:00
}
2021-06-27 03:09:39 +00:00
model LnAuth {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
k1 String @unique
pubkey String?
}
2021-10-28 19:59:53 +00:00
model LnWith {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
k1 String @unique
userId Int
withdrawalId Int?
}
2021-10-12 20:40:30 +00:00
model Invite {
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
user User @relation(name: "Invites", fields: [userId], references: [id])
userId Int
gift Int?
limit Int?
revoked Boolean @default(false)
invitees User[]
2022-03-10 19:26:35 +00:00
@@index([userId])
@@index([createdAt])
2021-10-12 20:40:30 +00:00
}
2021-03-25 19:29:24 +00:00
model Message {
id Int @id @default(autoincrement())
text String
user User @relation(fields: [userId], references: [id])
userId Int
}
2022-02-25 17:34:09 +00:00
enum Status {
ACTIVE
STOPPED
NOSATS
}
2021-03-25 19:29:24 +00:00
model Item {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
title String?
text String?
url String?
user User @relation("UserItems", fields: [userId], references: [id])
userId Int
fwdUser User? @relation(name: "FwdItem", fields: [fwdUserId], references: [id])
fwdUserId Int?
parent Item? @relation("ParentChildren", fields: [parentId], references: [id])
parentId Int?
children Item[] @relation("ParentChildren")
actions ItemAct[]
mentions Mention[]
path Unsupported("LTREE")?
pin Pin? @relation(fields: [pinId], references: [id])
pinId Int?
boost Int @default(0)
uploadId Int?
upload Upload?
paidImgLink Boolean @default(false)
2022-09-27 21:19:15 +00:00
// is free post or bio
freebie Boolean @default(false)
bio Boolean @default(false)
// denormalized self stats
2022-09-21 19:57:36 +00:00
weightedVotes Float @default(0)
weightedDownVotes Float @default(0)
sats Int @default(0)
// denormalized comment stats
ncomments Int @default(0)
commentSats Int @default(0)
lastCommentAt DateTime?
2021-03-25 19:29:24 +00:00
2022-02-17 17:23:43 +00:00
// if sub is null, this is the main sub
sub Sub? @relation(fields: [subName], references: [name])
subName String? @db.Citext
// fields exclusively for job post types right now
2022-02-26 21:42:38 +00:00
minSalary Int?
maxSalary Int?
maxBid Int?
status Status @default(ACTIVE)
statusUpdatedAt DateTime?
location String?
2022-03-07 21:50:13 +00:00
company String?
2022-02-26 21:42:38 +00:00
latitude Float?
longitude Float?
remote Boolean?
2022-02-17 17:23:43 +00:00
2022-07-30 13:25:46 +00:00
// fields for polls
pollCost Int?
User User[]
PollOption PollOption[]
PollVote PollVote[]
2022-08-06 22:03:57 +00:00
2021-10-06 14:43:32 +00:00
@@index([createdAt])
2021-03-25 19:29:24 +00:00
@@index([userId])
@@index([parentId])
2022-03-10 19:17:30 +00:00
@@index([status])
@@index([maxBid])
@@index([statusUpdatedAt])
@@index([subName])
@@index([pinId])
2022-04-12 21:09:12 +00:00
@@index([path])
2021-03-25 19:29:24 +00:00
}
2022-07-30 13:25:46 +00:00
model PollOption {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
itemId Int
item Item @relation(fields: [itemId], references: [id])
option String
PollVote PollVote[]
2022-08-06 22:03:57 +00:00
2022-07-30 13:25:46 +00:00
@@index([itemId])
}
model PollVote {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
userId Int
user User @relation(fields: [userId], references: [id])
itemId Int
item Item @relation(fields: [itemId], references: [id])
pollOptionId Int
pollOption PollOption @relation(fields: [pollOptionId], references: [id])
@@unique([itemId, userId])
@@index([userId])
@@index([pollOptionId])
}
2022-02-17 17:23:43 +00:00
enum PostType {
LINK
DISCUSSION
JOB
2022-07-30 13:25:46 +00:00
POLL
2022-02-17 17:23:43 +00:00
}
enum RankingType {
WOT
RECENT
AUCTION
}
model Sub {
name String @id @db.Citext
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
postTypes PostType[]
rankingType RankingType
baseCost Int @default(1)
desc String?
Item Item[]
}
2022-01-07 16:32:31 +00:00
// the active pin is the latest one when it's a recurring cron
model Pin {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
cron String?
timezone String?
position Int
Item Item[]
}
2021-09-08 21:51:23 +00:00
enum ItemActType {
2021-09-08 21:15:06 +00:00
VOTE
BOOST
TIP
2022-03-16 16:35:51 +00:00
STREAM
2022-07-30 13:25:46 +00:00
POLL
2022-09-21 19:57:36 +00:00
DONT_LIKE_THIS
2021-09-08 21:15:06 +00:00
}
2021-09-08 21:51:23 +00:00
model ItemAct {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
sats Int
act ItemActType
item Item @relation(fields: [itemId], references: [id])
2021-04-22 22:14:32 +00:00
itemId Int
2021-09-08 21:51:23 +00:00
user User @relation(fields: [userId], references: [id])
2021-04-22 22:14:32 +00:00
userId Int
@@index([itemId])
@@index([userId])
2021-09-08 21:51:23 +00:00
@@index([act])
2021-10-06 14:43:32 +00:00
@@index([createdAt])
2021-04-22 22:14:32 +00:00
}
2021-08-18 22:20:33 +00:00
model Mention {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
item Item @relation(fields: [itemId], references: [id])
itemId Int
user User @relation(fields: [userId], references: [id])
userId Int
@@unique([itemId, userId])
2021-10-06 14:43:32 +00:00
@@index([createdAt])
2021-08-18 22:20:33 +00:00
@@index([itemId])
@@index([userId])
}
2021-05-11 15:52:50 +00:00
model Invoice {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
user User @relation(fields: [userId], references: [id])
userId Int
hash String @unique
bolt11 String
expiresAt DateTime
confirmedAt DateTime?
msatsRequested Int
msatsReceived Int?
cancelled Boolean @default(false)
2021-10-06 14:43:32 +00:00
@@index([createdAt])
2021-05-11 15:52:50 +00:00
@@index([userId])
}
2021-05-12 23:04:19 +00:00
enum WithdrawlStatus {
2021-05-13 21:19:51 +00:00
CONFIRMED
2021-05-12 23:04:19 +00:00
INSUFFICIENT_BALANCE
INVALID_PAYMENT
PATHFINDING_TIMEOUT
ROUTE_NOT_FOUND
2021-05-13 21:19:51 +00:00
UNKNOWN_FAILURE
2021-05-12 23:04:19 +00:00
}
model Withdrawl {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
user User @relation(fields: [userId], references: [id])
userId Int
hash String
2021-05-12 23:04:19 +00:00
bolt11 String
msatsPaying Int
msatsPaid Int?
msatsFeePaying Int
msatsFeePaid Int?
status WithdrawlStatus?
2022-08-06 22:03:57 +00:00
2021-10-06 14:43:32 +00:00
@@index([createdAt])
2021-05-12 23:04:19 +00:00
@@index([userId])
}
2021-03-25 19:29:24 +00:00
model Account {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
compoundId String @unique @map(name: "compound_id")
userId Int @map(name: "user_id")
providerType String @map(name: "provider_type")
providerId String @map(name: "provider_id")
providerAccountId String @map(name: "provider_account_id")
refreshToken String? @map(name: "refresh_token")
accessToken String? @map(name: "access_token")
accessTokenExpires DateTime? @map(name: "access_token_expires")
@@index([providerAccountId])
@@index([providerId])
@@index([userId])
@@map(name: "accounts")
}
model Session {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
userId Int @map(name: "user_id")
expires DateTime
sessionToken String @unique @map(name: "session_token")
accessToken String @unique @map(name: "access_token")
@@map(name: "sessions")
}
model VerificationRequest {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
identifier String
token String @unique
expires DateTime
@@map(name: "verification_requests")
}