-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
231 lines (211 loc) · 5.56 KB
/
schema.prisma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client {
provider = "prisma-client-js"
}
generator enums {
provider = "prisma-enums-generator"
output = "../src/graphql/schema/core/enums/types.graphql"
isExport = false
useComma = false
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum UserStatus {
User
Superadmin
}
model User {
id String @id @default(nanoid(12))
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
mobile String @unique
isVerified Boolean @default(false)
status UserStatus @default(User)
isBlocked Boolean @default(false)
password String
salt String @default("")
firstName String
lastName String?
codes Code[]
memberships Membership[]
}
model Code {
id String @id @default(nanoid(12))
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
expireAt DateTime
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
code String
}
model Portfolio {
id String @id @default(nanoid(12))
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String?
description String?
members Membership[]
funds PortfolioFund[]
stocks PortfolioStock[]
}
enum UserRole {
Member
Admin
}
model Membership {
id String @id @default(nanoid(12))
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
portfolioId String
portfolio Portfolio @relation(fields: [portfolioId], references: [id], onDelete: Cascade)
role UserRole @default(Member)
@@unique([userId, portfolioId])
}
enum FundPlan {
Direct
Regular
}
enum FundType {
BONUS
GROWTH
IDCW
IDCW_PAYOUT
IDCW_REINVESTMENT
IDCW_DAILY_PAYOUT
IDCW_DAILY_REINVESTMENT
IDCW_WEEKLY_PAYOUT
IDCW_WEEKLY_REINVESTMENT
IDCW_MONTHLY_PAYOUT
IDCW_MONTHLY_REINVESTMENT
IDCW_QUARTERLY_PAYOUT
IDCW_QUARTERLY_REINVESTMENT
IDCW_HALFYEARLY_PAYOUT
IDCW_HALFYEARLY_REINVESTMENT
IDCW_YEARLY_PAYOUT
IDCW_YEARLY_REINVESTMENT
}
enum FundCategory {
HYBRID_DYNAMIC_ASSET_ALLOCATION
HYBRID_MULTI_ASSET_ALLOCATION
HYBRID_ARBITRAGE
HYBRID_AGGRESSIVE
HYBRID_CONSERVATIVE
HYBRID_EQUITY_SAVINGS
EQUITY_ELSS
EQUITY_FOCUSED
EQUITY_DIVIDEND_YIELD
EQUITY_BANKING_AND_FINANCIAL_SERVICES
EQUITY_SECTORAL_TECHNOLOGY
EQUITY_SECTORAL_INFRASTRUCTURE
EQUITY_SECTORAL_PHARMA_AND_HEALTHCARE
EQUITY_THEMATIC_CONSUMPTION
EQUITY_THEMATIC_INTERNATIONAL
EQUITY_THEMATIC_MANUFACTURING
EQUITY_THEMATIC_TRANSPORTATION
EQUITY_THEMATIC_MNC
EQUITY_THEMATIC_PSU
EQUITY_THEMATIC_QUANTITATIVE
EQUITY_THEMATIC_ESG
EQUITY_THEMATIC_OTHERS
EQUITY_VALUE
EQUITY_FLEXI_CAP
EQUITY_LARGE_AND_MID_CAP
EQUITY_SMALL_CAP
EQUITY_MID_CAP
EQUITY_LARGE_CAP
EQUITY_MULTI_CAP
DEBT_DYNAMIC_BOND
DEBT_CORPORATE_BOND
DEBT_BANKING_AND_PSU
DEBT_LIQUID
DEBT_FLOATER
DEBT_GILT
DEBT_GILT_10_YEARS_CONSTANT
DEBT_MONEY_MARKET
DEBT_CREDIT_RISK
DEBT_MEDIUM_TO_LONG_DURATION
DEBT_LONG_DURATION
DEBT_LOW_DURATION
DEBT_MEDIUM_DURATION
DEBT_OVERNIGHT
DEBT_SHORT_DURATION
DEBT_ULTRA_SHORT_DURATION
FOF_DOMESTIC_DEBT
FOF_DOMESTIC_HYBRID
FOF_DOMESTIC_EQUITY
FOF_DOMESTIC_GOLD
FOF_DOMESTIC_SILVER
FOF_OVERSEAS
CHILDRENS_FUND
RETIREMENT_FUND
ETF
INDEX_FUND
}
model Fund {
id String @id @default(nanoid(12))
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
description String?
plan FundPlan @default(Direct)
type FundType?
category FundCategory?
// Generally fund has only one symbol, but just in case if we need to support multiple symbols
// to be to grab from other system or something
symbol1 String?
symbol2 String?
lastNav Float
PortfolioFunds PortfolioFund[]
}
model PortfolioFund {
id String @id @default(nanoid(18))
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
portfolioId String
portfolio Portfolio @relation(fields: [portfolioId], references: [id])
fundId String
fund Fund @relation(fields: [fundId], references: [id])
units Float @default(0)
cost Float @default(0)
@@unique([fundId, portfolioId])
}
enum Exchange {
// Bombay Stock Exchange
BSE
// National Stock Exchange
NSE
// New York
NYSE
// London
LSE
// NASDAQ
NASDAQ
}
model Stock {
id String @id @default(nanoid(12))
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
symbol String
exchange Exchange
lastPrice Float
PortfolioStocks PortfolioStock[]
}
model PortfolioStock {
id String @id @default(nanoid(22))
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
portfolioId String
portfolio Portfolio @relation(fields: [portfolioId], references: [id])
stockId String
stock Stock @relation(fields: [stockId], references: [id])
units Float @default(0)
cost Float @default(0)
}