97 lines
2.5 KiB
Plaintext
97 lines
2.5 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mysql"
|
|
url = "mysql://root:Zelen0ku4e@192.168.0.10:3306/trader"
|
|
//env("DATABASE_URL")
|
|
}
|
|
|
|
|
|
generator py {
|
|
provider = "prisma-client-py"
|
|
recursive_type_depth = 5
|
|
}
|
|
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
username String @unique
|
|
password String
|
|
ownedWallets Wallet[] @relation("UserWallets")
|
|
followedWallets WalletFollow[] // Intermediate table relation
|
|
|
|
}
|
|
|
|
model Wallet {
|
|
id Int @id @default(autoincrement())
|
|
publicKey String
|
|
privateKey String
|
|
userId Int
|
|
owner User @relation("UserWallets", fields: [userId], references: [id])
|
|
followers WalletFollow[] // Intermediate table relation
|
|
holdings Holding[]
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
// Intermediate table for many-to-many follow relationship
|
|
model WalletFollow {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
walletId Int
|
|
user User @relation(fields: [userId], references: [id])
|
|
wallet Wallet @relation(fields: [walletId], references: [id])
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([userId, walletId]) // Prevent duplicate follows
|
|
@@index([userId])
|
|
@@index([walletId])
|
|
}
|
|
|
|
model Holding {
|
|
id Int @id @default(autoincrement())
|
|
tokenMint String @unique
|
|
tokenName String
|
|
ammount Float
|
|
totalAcquisitionValueUSD Float
|
|
totalSellValueUSD Float
|
|
walletId Int
|
|
wallet Wallet @relation(fields: [walletId], references: [id])
|
|
transactions Transaction[]
|
|
pnl Float @default(0.0)
|
|
|
|
}
|
|
|
|
enum TransactionStatus {
|
|
ORIGINAL
|
|
ORIGINAL_FOLLOWED
|
|
PENDING
|
|
FAILED
|
|
SENT
|
|
CONFIRMED
|
|
}
|
|
|
|
model Transaction {
|
|
id Int @id @default(autoincrement())
|
|
transactionId String
|
|
amount Float @default(0.0)
|
|
date DateTime @default(now())
|
|
amountUSD Float @default(0.0)
|
|
holdingId Int
|
|
holding Holding @relation(fields: [holdingId], references: [id])
|
|
isClosed Boolean @default(false)
|
|
status TransactionStatus @default(ORIGINAL)
|
|
originalId Int?
|
|
original Transaction? @relation("OriginalTransaction", fields: [originalId], references: [id])
|
|
relatedTo Transaction[] @relation("OriginalTransaction")
|
|
timestamp DateTime @default(now())
|
|
}
|
|
|
|
model Timeseries {
|
|
id Int @id @default(autoincrement())
|
|
timestamp DateTime @default(now())
|
|
data String
|
|
}
|