@@ -0,0 +1,146 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum HouseholdType {
|
||||
SINGLE
|
||||
COUPLE
|
||||
}
|
||||
|
||||
enum IncomeMode {
|
||||
PER_PERSON
|
||||
HOUSEHOLD
|
||||
}
|
||||
|
||||
enum OneTimeEventType {
|
||||
INCOME
|
||||
EXPENSE
|
||||
}
|
||||
|
||||
enum TransitionAction {
|
||||
CARRY_OVER
|
||||
PAYOUT
|
||||
SELL
|
||||
}
|
||||
|
||||
model Plan {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
householdType HouseholdType @default(SINGLE)
|
||||
person1Name String @default("Person 1")
|
||||
person1CurrentAge Int
|
||||
person2Name String?
|
||||
person2CurrentAge Int?
|
||||
plannedRetirementAge Int @default(65)
|
||||
defaultInflationRate Float @default(2.0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
scenarios Scenario[]
|
||||
}
|
||||
|
||||
model Scenario {
|
||||
id String @id @default(cuid())
|
||||
planId String
|
||||
name String
|
||||
isBaseline Boolean @default(false)
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
plan Plan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
||||
phases LifePhase[]
|
||||
|
||||
@@index([planId])
|
||||
}
|
||||
|
||||
model LifePhase {
|
||||
id String @id @default(cuid())
|
||||
scenarioId String
|
||||
name String
|
||||
sortOrder Int
|
||||
durationYears Int
|
||||
isRetirementPhase Boolean @default(false)
|
||||
incomeMode IncomeMode @default(PER_PERSON)
|
||||
householdIncome Float?
|
||||
person1Income Float?
|
||||
person2Income Float?
|
||||
householdExpenses Float @default(0)
|
||||
inflationRate Float?
|
||||
expectedPensionIncome Float?
|
||||
expectedPensionCapital Float?
|
||||
pensionCapitalTaxRate Float?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
scenario Scenario @relation(fields: [scenarioId], references: [id], onDelete: Cascade)
|
||||
securities Security[]
|
||||
properties Property[]
|
||||
oneTimeEvents OneTimeEvent[]
|
||||
transitionFrom PhaseTransition? @relation("TransitionFrom")
|
||||
transitionTo PhaseTransition? @relation("TransitionTo")
|
||||
|
||||
@@index([scenarioId])
|
||||
}
|
||||
|
||||
model Security {
|
||||
id String @id @default(cuid())
|
||||
lifePhaseId String
|
||||
name String
|
||||
ownerTag String?
|
||||
startBalance Float @default(0)
|
||||
expectedReturnRate Float @default(5.0)
|
||||
annualSavingsAllocation Float @default(0)
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
lifePhase LifePhase @relation(fields: [lifePhaseId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([lifePhaseId])
|
||||
}
|
||||
|
||||
model Property {
|
||||
id String @id @default(cuid())
|
||||
lifePhaseId String
|
||||
name String
|
||||
currentValue Float @default(0)
|
||||
mortgageBalance Float @default(0)
|
||||
valueGrowthRate Float @default(2.0)
|
||||
annualAmortization Float @default(0)
|
||||
saleTaxRatePercent Float?
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
lifePhase LifePhase @relation(fields: [lifePhaseId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([lifePhaseId])
|
||||
}
|
||||
|
||||
model OneTimeEvent {
|
||||
id String @id @default(cuid())
|
||||
lifePhaseId String
|
||||
name String
|
||||
yearOffset Int
|
||||
amount Float
|
||||
type OneTimeEventType
|
||||
taxRatePercent Float?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
lifePhase LifePhase @relation(fields: [lifePhaseId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([lifePhaseId])
|
||||
}
|
||||
|
||||
model PhaseTransition {
|
||||
id String @id @default(cuid())
|
||||
fromPhaseId String @unique
|
||||
toPhaseId String @unique
|
||||
securityActions Json @default("[]")
|
||||
propertyActions Json @default("[]")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
fromPhase LifePhase @relation("TransitionFrom", fields: [fromPhaseId], references: [id], onDelete: Cascade)
|
||||
toPhase LifePhase @relation("TransitionTo", fields: [toPhaseId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
Reference in New Issue
Block a user