101 lines
2.7 KiB
Plaintext
101 lines
2.7 KiB
Plaintext
// 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)
|
|
initialBalance Float @default(0) // Solde de départ pour équilibrer
|
|
currency String @default("EUR")
|
|
lastImport String?
|
|
externalUrl String? // Custom URL for external bank portal
|
|
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[]
|
|
|
|
@@index([parentId])
|
|
}
|
|
|
|
model Backup {
|
|
id String @id @default(cuid())
|
|
filename String
|
|
filePath String
|
|
size Int // Size in bytes
|
|
dataHash String? // Hash of the actual data (excluding Backup table)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([createdAt])
|
|
}
|