added api logic, vitest, minimal testing ui
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
// prisma/schema.prisma
|
||||
generator client { provider = "prisma-client-js" }
|
||||
datasource db { provider = "postgresql"; url = env("DATABASE_URL") }
|
||||
// prisma/schema.prisma
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
binaryTargets = ["native", "debian-openssl-3.0.x"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
@@ -25,63 +32,59 @@ model VariableCategory {
|
||||
balanceCents BigInt @default(0)
|
||||
|
||||
@@unique([userId, name])
|
||||
@@check(percent_gte_0, "percent >= 0")
|
||||
@@check(percent_lte_100,"percent <= 100")
|
||||
@@index([userId, priority])
|
||||
}
|
||||
|
||||
model FixedPlan {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
cycleStart DateTime
|
||||
dueOn DateTime
|
||||
totalCents BigInt
|
||||
fundedCents BigInt @default(0)
|
||||
priority Int @default(100)
|
||||
fundingMode String @default("auto-on-deposit") // or 'by-schedule'
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
cycleStart DateTime
|
||||
dueOn DateTime
|
||||
totalCents BigInt
|
||||
fundedCents BigInt @default(0)
|
||||
priority Int @default(100)
|
||||
fundingMode String @default("auto-on-deposit")
|
||||
scheduleJson Json?
|
||||
|
||||
@@unique([userId, name])
|
||||
@@check(total_nonneg, "totalCents >= 0")
|
||||
@@check(funded_nonneg, "fundedCents >= 0")
|
||||
@@index([userId, dueOn])
|
||||
@@index([userId, priority])
|
||||
}
|
||||
|
||||
model IncomeEvent {
|
||||
id String @id @default(uuid())
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
postedAt DateTime
|
||||
amountCents BigInt
|
||||
|
||||
allocations Allocation[]
|
||||
|
||||
@@check(pos_amount, "amountCents > 0")
|
||||
@@index([userId, postedAt])
|
||||
}
|
||||
|
||||
model Allocation {
|
||||
id String @id @default(uuid())
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
kind String // 'savings' | 'variable' | 'fixed'
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
kind String
|
||||
toId String
|
||||
amountCents BigInt
|
||||
incomeId String?
|
||||
income IncomeEvent? @relation(fields: [incomeId], references: [id])
|
||||
|
||||
@@check(pos_amount, "amountCents > 0")
|
||||
}
|
||||
|
||||
model Transaction {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
occurredAt DateTime
|
||||
kind String // 'variable-spend' | 'fixed-payment'
|
||||
categoryId String?
|
||||
planId String?
|
||||
amountCents BigInt
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
occurredAt DateTime
|
||||
kind String
|
||||
categoryId String?
|
||||
planId String?
|
||||
amountCents BigInt
|
||||
|
||||
@@check(pos_amount, "amountCents > 0")
|
||||
@@index([userId, occurredAt])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user