95 lines
2.4 KiB
Plaintext
95 lines
2.4 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
}
|
|
|
|
model Portfolio {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
name String
|
|
description String?
|
|
currency String @default("RUB")
|
|
targets String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
positions Position[]
|
|
|
|
@@unique([userId, name])
|
|
}
|
|
|
|
model Position {
|
|
id Int @id @default(autoincrement())
|
|
portfolioId Int
|
|
secid String
|
|
type String @default("share")
|
|
quantity Int
|
|
buyPrice Float?
|
|
buyDate DateTime?
|
|
notes String?
|
|
tags String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
portfolio Portfolio @relation(fields: [portfolioId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([portfolioId, secid])
|
|
}
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
email String @unique
|
|
password String
|
|
name String?
|
|
role String @default("user")
|
|
refreshToken String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
portfolios Portfolio[]
|
|
}
|
|
|
|
model BrokerOperation {
|
|
id Int @id @default(autoincrement())
|
|
accountId String
|
|
cursor String?
|
|
operationId String?
|
|
parentOperationId String?
|
|
date DateTime?
|
|
type String
|
|
category String
|
|
state String?
|
|
instrumentUid String?
|
|
figi String?
|
|
ticker String?
|
|
classCode String?
|
|
payment String?
|
|
price String?
|
|
commission String?
|
|
yield String?
|
|
accruedInt String?
|
|
quantity Int?
|
|
quantityDone Int?
|
|
raw String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([accountId, cursor])
|
|
@@index([accountId, date])
|
|
@@index([accountId, type])
|
|
}
|
|
|
|
model BrokerOperationSyncState {
|
|
id Int @id @default(autoincrement())
|
|
accountId String @unique
|
|
lastCursor String?
|
|
lastSyncedFrom DateTime?
|
|
lastSyncedTo DateTime?
|
|
syncedAt DateTime @default(now())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|