moex-vibe/apps/backend/prisma/schema.prisma
Sergey Krylov a980520261
Some checks failed
CI / lint (pull_request) Successful in 1m59s
CI / test (pull_request) Successful in 1m45s
CI / build (pull_request) Failing after 1m54s
CI / lint (push) Successful in 1m50s
CI / test (push) Successful in 1m47s
CI / build (push) Failing after 2m3s
feat: portfolio management with share/bond separation
- Add Portfolio + Position models (Prisma + migrations)
- Backend: PortfolioModule with CRUD, enrichment, type detection
- Backend: enrichBondPosition returns 13 financial fields (YTM, duration,
  coupon, NCD, accrued interest, bid/offer, bondType, offerDate, etc.)
- Frontend: portfolio pages, 4 TanStack Query hooks, split share/bond tables
- Fix: MOEX bond marketdata board fallback (TQCB → TQOB for OFZ)
- Frontend: clickable ticker links to /stocks/:secid and /bonds/:secid
- Remove: target allocation, deviation, tags display from Phase 1
- Docs: ADR-009 (domain model), ADR-010 (price computation),
  portfolio backend doc, superpowers spec + plan
2026-06-14 11:14:04 +03:00

52 lines
1.2 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
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[]
}