chore: init from v0
This commit is contained in:
101
prisma/schema.prisma
Normal file
101
prisma/schema.prisma
Normal file
@@ -0,0 +1,101 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
bankId String
|
||||
accountNumber String
|
||||
type String // CHECKING | SAVINGS | CREDIT_CARD | OTHER
|
||||
folderId String?
|
||||
balance Float @default(0)
|
||||
currency String @default("EUR")
|
||||
lastImport String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
folder Folder? @relation(fields: [folderId], references: [id], onDelete: SetNull)
|
||||
transactions Transaction[]
|
||||
|
||||
@@index([folderId])
|
||||
}
|
||||
|
||||
model Transaction {
|
||||
id String @id @default(cuid())
|
||||
accountId String
|
||||
date String
|
||||
amount Float
|
||||
description String
|
||||
type String // DEBIT | CREDIT
|
||||
categoryId String?
|
||||
isReconciled Boolean @default(false)
|
||||
fitId String // OFX unique transaction ID
|
||||
memo String?
|
||||
checkNum String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
account Account @relation(fields: [accountId], references: [id], onDelete: Cascade)
|
||||
category Category? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@unique([accountId, fitId])
|
||||
@@index([accountId])
|
||||
@@index([categoryId])
|
||||
@@index([date])
|
||||
}
|
||||
|
||||
model Folder {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
parentId String?
|
||||
color String
|
||||
icon String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
parent Folder? @relation("FolderHierarchy", fields: [parentId], references: [id], onDelete: Cascade)
|
||||
children Folder[] @relation("FolderHierarchy")
|
||||
accounts Account[]
|
||||
|
||||
@@index([parentId])
|
||||
}
|
||||
|
||||
model Category {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
color String
|
||||
icon String
|
||||
keywords String // JSON array stored as string
|
||||
parentId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
parent Category? @relation("CategoryHierarchy", fields: [parentId], references: [id], onDelete: Cascade)
|
||||
children Category[] @relation("CategoryHierarchy")
|
||||
transactions Transaction[]
|
||||
rules CategoryRule[]
|
||||
|
||||
@@index([parentId])
|
||||
}
|
||||
|
||||
model CategoryRule {
|
||||
id String @id @default(cuid())
|
||||
categoryId String
|
||||
pattern String
|
||||
isRegex Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([categoryId])
|
||||
}
|
||||
Reference in New Issue
Block a user