chore: scaffold Next.js + Prisma schema + dev MariaDB
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c4cee91ed7
commit
8d41c2fffe
27 files changed
+9616
No files matched your search
@@ -0,0 +1,201 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum OpKind {
|
||||
INCOME
|
||||
EXPENSE
|
||||
}
|
||||
|
||||
enum OpStatus {
|
||||
PLANNED
|
||||
ACTUAL
|
||||
SKIPPED
|
||||
}
|
||||
|
||||
enum AllocationMode {
|
||||
REDUCE_SHARED
|
||||
BENEFICIARY_ONLY
|
||||
CUSTOM
|
||||
}
|
||||
|
||||
enum Frequency {
|
||||
MONTHLY
|
||||
QUARTERLY
|
||||
YEARLY
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
firstName String
|
||||
login String @unique
|
||||
passwordHash String
|
||||
color String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
accountOperations Operation[] @relation("OperationAccount")
|
||||
createdOperations Operation[] @relation("OperationCreator")
|
||||
operationSplits OperationSplit[]
|
||||
recurrings Recurring[]
|
||||
recurringSplits RecurringSplit[]
|
||||
settlementsFrom Settlement[] @relation("SettlementFrom")
|
||||
settlementsTo Settlement[] @relation("SettlementTo")
|
||||
loans Loan[]
|
||||
loanSplits LoanSplit[]
|
||||
}
|
||||
|
||||
model Setting {
|
||||
id Int @id @default(1)
|
||||
defaultSplit Json
|
||||
}
|
||||
|
||||
model Category {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
emoji String
|
||||
kind OpKind
|
||||
archived Boolean @default(false)
|
||||
sortOrder Int @default(0)
|
||||
operations Operation[]
|
||||
recurrings Recurring[]
|
||||
budgets Budget[]
|
||||
|
||||
@@unique([name, kind])
|
||||
}
|
||||
|
||||
model Operation {
|
||||
id String @id @default(cuid())
|
||||
kind OpKind
|
||||
amount Decimal @db.Decimal(12, 2)
|
||||
date DateTime @db.Date
|
||||
label String
|
||||
note String? @db.Text
|
||||
categoryId String
|
||||
category Category @relation(fields: [categoryId], references: [id], onDelete: Restrict)
|
||||
accountUserId String
|
||||
accountUser User @relation("OperationAccount", fields: [accountUserId], references: [id])
|
||||
status OpStatus
|
||||
recurringId String?
|
||||
recurring Recurring? @relation("RecurringOccurrences", fields: [recurringId], references: [id], onDelete: SetNull)
|
||||
occurrenceDate DateTime? @db.Date
|
||||
|
||||
allocatedToRecurringId String?
|
||||
allocatedToRecurring Recurring? @relation("OperationAllocatedToRecurring", fields: [allocatedToRecurringId], references: [id], onDelete: SetNull)
|
||||
allocatedToOperationId String?
|
||||
allocatedToOperation Operation? @relation("OperationAllocatedToOperation", fields: [allocatedToOperationId], references: [id], onDelete: SetNull, onUpdate: NoAction)
|
||||
allocatedFrom Operation[] @relation("OperationAllocatedToOperation")
|
||||
allocationMode AllocationMode?
|
||||
|
||||
splits OperationSplit[]
|
||||
createdById String
|
||||
createdBy User @relation("OperationCreator", fields: [createdById], references: [id])
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([recurringId, occurrenceDate])
|
||||
@@index([date])
|
||||
}
|
||||
|
||||
model OperationSplit {
|
||||
operationId String
|
||||
operation Operation @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
basisPoints Int
|
||||
|
||||
@@id([operationId, userId])
|
||||
}
|
||||
|
||||
model Recurring {
|
||||
id String @id @default(cuid())
|
||||
kind OpKind
|
||||
amount Decimal @db.Decimal(12, 2)
|
||||
label String
|
||||
categoryId String
|
||||
category Category @relation(fields: [categoryId], references: [id], onDelete: Restrict)
|
||||
accountUserId String
|
||||
accountUser User @relation(fields: [accountUserId], references: [id])
|
||||
frequency Frequency
|
||||
dayOfMonth Int
|
||||
startDate DateTime @db.Date
|
||||
endDate DateTime? @db.Date
|
||||
paused Boolean @default(false)
|
||||
loanId String? @unique
|
||||
loan Loan? @relation(fields: [loanId], references: [id], onDelete: Cascade)
|
||||
|
||||
allocatedToRecurringId String?
|
||||
allocatedToRecurring Recurring? @relation("RecurringAllocatedToRecurring", fields: [allocatedToRecurringId], references: [id], onDelete: SetNull, onUpdate: NoAction)
|
||||
allocatedFrom Recurring[] @relation("RecurringAllocatedToRecurring")
|
||||
allocationMode AllocationMode?
|
||||
|
||||
splits RecurringSplit[]
|
||||
occurrences Operation[] @relation("RecurringOccurrences")
|
||||
allocatedOperations Operation[] @relation("OperationAllocatedToRecurring")
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model RecurringSplit {
|
||||
recurringId String
|
||||
recurring Recurring @relation(fields: [recurringId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
basisPoints Int
|
||||
|
||||
@@id([recurringId, userId])
|
||||
}
|
||||
|
||||
model Settlement {
|
||||
id String @id @default(cuid())
|
||||
fromUserId String
|
||||
fromUser User @relation("SettlementFrom", fields: [fromUserId], references: [id])
|
||||
toUserId String
|
||||
toUser User @relation("SettlementTo", fields: [toUserId], references: [id])
|
||||
amount Decimal @db.Decimal(12, 2)
|
||||
date DateTime @db.Date
|
||||
note String?
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model Budget {
|
||||
id String @id @default(cuid())
|
||||
categoryId String
|
||||
category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
||||
monthlyAmount Decimal @db.Decimal(12, 2)
|
||||
startMonth String @db.Char(7)
|
||||
endMonth String? @db.Char(7)
|
||||
}
|
||||
|
||||
model Loan {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
lender String?
|
||||
principal Decimal @db.Decimal(12, 2)
|
||||
annualRate Decimal @db.Decimal(6, 3)
|
||||
durationMonths Int
|
||||
startDate DateTime @db.Date
|
||||
insuranceMonthly Decimal @default(0) @db.Decimal(12, 2)
|
||||
accountUserId String
|
||||
accountUser User @relation(fields: [accountUserId], references: [id])
|
||||
paymentOverride Decimal? @db.Decimal(12, 2)
|
||||
referenceDate DateTime? @db.Date
|
||||
referenceRemainingCapital Decimal? @db.Decimal(12, 2)
|
||||
splits LoanSplit[]
|
||||
recurring Recurring?
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model LoanSplit {
|
||||
loanId String
|
||||
loan Loan @relation(fields: [loanId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
basisPoints Int
|
||||
|
||||
@@id([loanId, userId])
|
||||
}
|
||||
Reference in new issue
Block a user