You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ghostfolio/prisma/schema.prisma

212 lines
4.8 KiB

4 years ago
// 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"
binaryTargets = ["debian-openssl-1.1.x", "native"]
previewFeatures = ["orderByRelation", "selectRelationCount"]
}
model Access {
createdAt DateTime @default(now())
GranteeUser User? @relation(fields: [granteeUserId], name: "accessGet", references: [id])
granteeUserId String?
4 years ago
id String @default(uuid())
updatedAt DateTime @updatedAt
User User @relation(fields: [userId], name: "accessGive", references: [id])
userId String
@@id([id, userId])
}
model Account {
accountType AccountType @default(SECURITIES)
balance Float @default(0)
createdAt DateTime @default(now())
currency String?
id String @default(uuid())
isDefault Boolean @default(false)
name String?
Order Order[]
Platform Platform? @relation(fields: [platformId], references: [id])
platformId String?
updatedAt DateTime @updatedAt
User User @relation(fields: [userId], references: [id])
userId String
@@id([id, userId])
}
4 years ago
model Analytics {
activityCount Int @default(0)
updatedAt DateTime @updatedAt
User User @relation(fields: [userId], references: [id])
userId String @id
}
model AuthDevice {
createdAt DateTime @default(now())
credentialId Bytes
credentialPublicKey Bytes
counter Int
id String @id @default(uuid())
updatedAt DateTime @updatedAt
User User @relation(fields: [userId], references: [id])
userId String
}
4 years ago
model MarketData {
createdAt DateTime @default(now())
dataSource DataSource
4 years ago
date DateTime
id String @default(uuid())
4 years ago
symbol String
marketPrice Float
@@unique([date, symbol])
@@index(fields: [symbol])
}
model Order {
Account Account? @relation(fields: [accountId, accountUserId], references: [id, userId])
accountId String?
accountUserId String?
createdAt DateTime @default(now())
currency String?
dataSource DataSource
date DateTime
fee Float
id String @default(uuid())
isDraft Boolean @default(false)
quantity Float
symbol String
SymbolProfile SymbolProfile? @relation(fields: [symbolProfileId], references: [id])
symbolProfileId String?
type Type
unitPrice Float
updatedAt DateTime @updatedAt
User User @relation(fields: [userId], references: [id])
userId String
4 years ago
@@id([id, userId])
}
model Platform {
Account Account[]
id String @id @default(uuid())
name String?
url String @unique
4 years ago
}
model Property {
key String @id
value String
}
model Settings {
currency String?
settings Json?
updatedAt DateTime @updatedAt
viewMode ViewMode?
User User @relation(fields: [userId], references: [id])
userId String @id
4 years ago
}
model SymbolProfile {
assetClass AssetClass?
assetSubClass AssetSubClass?
countries Json?
createdAt DateTime @default(now())
currency String?
dataSource DataSource
id String @id @default(uuid())
name String?
Order Order[]
updatedAt DateTime @updatedAt
sectors Json?
symbol String
@@unique([dataSource, symbol])
}
model Subscription {
createdAt DateTime @default(now())
expiresAt DateTime
id String @default(uuid())
updatedAt DateTime @updatedAt
User User @relation(fields: [userId], references: [id])
userId String
@@id([id, userId])
}
4 years ago
model User {
Access Access[] @relation("accessGet")
AccessGive Access[] @relation(name: "accessGive")
accessToken String?
Account Account[]
alias String?
Analytics Analytics?
authChallenge String?
AuthDevice AuthDevice[]
createdAt DateTime @default(now())
id String @id @default(uuid())
Order Order[]
provider Provider?
role Role @default(USER)
Settings Settings?
Subscription Subscription[]
thirdPartyId String?
updatedAt DateTime @updatedAt
4 years ago
}
enum AccountType {
CASH
SECURITIES
}
enum AssetClass {
CASH
COMMODITY
EQUITY
}
enum AssetSubClass {
CRYPTOCURRENCY
ETF
STOCK
}
enum DataSource {
ALPHA_VANTAGE
GHOSTFOLIO
RAKUTEN
YAHOO
}
enum ViewMode {
DEFAULT
ZEN
}
4 years ago
enum Provider {
ANONYMOUS
GOOGLE
}
enum Role {
ADMIN
DEMO
USER
}
enum Type {
BUY
SELL
}