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 {
|
2021-09-08 21:51:23 +00:00
|
|
|
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")
|
2021-06-24 23:56:01 +00:00
|
|
|
image String?
|
|
|
|
items Item[]
|
2021-08-18 22:20:33 +00:00
|
|
|
mentions Mention[]
|
2021-06-24 23:56:01 +00:00
|
|
|
messages Message[]
|
2021-09-09 19:10:15 +00:00
|
|
|
actions ItemAct[]
|
2021-06-24 23:56:01 +00:00
|
|
|
invoices Invoice[]
|
|
|
|
withdrawls Withdrawl[]
|
2021-10-12 20:40:30 +00:00
|
|
|
invites Invite[] @relation(name: "Invites")
|
|
|
|
invite Invite? @relation(fields: [inviteId], references: [id])
|
|
|
|
inviteId String?
|
2021-09-23 17:42:00 +00:00
|
|
|
bio Item? @relation(name: "Item", fields: [bioId], references: [id])
|
|
|
|
bioId Int?
|
2021-09-08 21:51:23 +00:00
|
|
|
msats Int @default(0)
|
|
|
|
freeComments Int @default(5)
|
|
|
|
freePosts Int @default(2)
|
2021-06-24 23:56:01 +00:00
|
|
|
checkedNotesAt DateTime?
|
2021-12-13 19:49:34 +00:00
|
|
|
tipDefault Int @default(1)
|
2021-09-08 21:51:23 +00:00
|
|
|
pubkey String? @unique
|
2022-01-14 17:28:05 +00:00
|
|
|
trust Float @default(0)
|
2021-03-25 19:29:24 +00:00
|
|
|
|
2021-12-09 20:40:40 +00:00
|
|
|
upvotePopover Boolean @default(false)
|
|
|
|
tipPopover Boolean @default(false)
|
|
|
|
|
2021-10-06 14:43:32 +00:00
|
|
|
@@index([createdAt])
|
2021-03-25 19:29:24 +00:00
|
|
|
@@map(name: "users")
|
|
|
|
}
|
|
|
|
|
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[]
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
model Item {
|
2021-04-12 18:05:09 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map(name: "created_at")
|
2022-01-07 16:32:31 +00:00
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
|
2021-04-14 00:57:32 +00:00
|
|
|
title String?
|
2021-04-12 18:05:09 +00:00
|
|
|
text String?
|
|
|
|
url String?
|
|
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
userId Int
|
|
|
|
parent Item? @relation("ParentChildren", fields: [parentId], references: [id])
|
|
|
|
parentId Int?
|
|
|
|
children Item[] @relation("ParentChildren")
|
2021-09-08 21:51:23 +00:00
|
|
|
actions ItemAct[]
|
2021-08-18 22:20:33 +00:00
|
|
|
mentions Mention[]
|
2021-04-12 18:05:09 +00:00
|
|
|
path Unsupported("LTREE")?
|
2022-01-07 16:32:31 +00:00
|
|
|
pin Pin? @relation(fields: [pinId], references: [id])
|
|
|
|
pinId Int?
|
2021-03-25 19:29:24 +00:00
|
|
|
|
2021-09-23 17:42:00 +00:00
|
|
|
User User[] @relation("Item")
|
2022-01-07 16:32:31 +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-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
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2021-07-10 14:16:40 +00:00
|
|
|
hash String
|
2021-05-12 23:04:19 +00:00
|
|
|
bolt11 String
|
|
|
|
msatsPaying Int
|
|
|
|
msatsPaid Int?
|
|
|
|
msatsFeePaying Int
|
|
|
|
msatsFeePaid Int?
|
|
|
|
|
|
|
|
status WithdrawlStatus?
|
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")
|
|
|
|
}
|