124 lines
3.0 KiB
Plaintext
124 lines
3.0 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
status String @default("active")
|
|
email String? @unique
|
|
name String?
|
|
avatarUrl String?
|
|
defaultCurrency String?
|
|
timeZone String?
|
|
authAccounts AuthAccount[]
|
|
categories Category[]
|
|
Recurrence Recurrence[]
|
|
sessions Session[]
|
|
transactions Transaction[]
|
|
wallets Wallet[]
|
|
}
|
|
|
|
model AuthAccount {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
provider String
|
|
issuer String
|
|
subject String
|
|
lastLogin DateTime @default(now())
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@unique([issuer, subject])
|
|
@@index([userId])
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
createdAt DateTime @default(now())
|
|
expiresAt DateTime
|
|
ip String?
|
|
userAgent String?
|
|
revokedAt DateTime?
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
model Wallet {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
kind String
|
|
name String
|
|
currency String?
|
|
unit String?
|
|
initialAmount Decimal? @db.Decimal(18, 2)
|
|
pricePerUnit Decimal? @db.Decimal(18, 2)
|
|
deletedAt DateTime?
|
|
transactions Transaction[]
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
model Category {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
name String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@unique([userId, name])
|
|
@@index([userId])
|
|
}
|
|
|
|
model Transaction {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
walletId String
|
|
createdAt DateTime @default(now())
|
|
date DateTime
|
|
amount Decimal @db.Decimal(18, 2)
|
|
direction String
|
|
category String?
|
|
memo String?
|
|
recurrenceId String?
|
|
user User @relation(fields: [userId], references: [id])
|
|
wallet Wallet @relation(fields: [walletId], references: [id])
|
|
|
|
@@index([userId, walletId, date])
|
|
}
|
|
|
|
model Recurrence {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
rule String
|
|
nextRunAt DateTime
|
|
lastRunAt DateTime?
|
|
idempotency String @unique
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
model CurrencyRate {
|
|
id String @id @default(uuid())
|
|
base String
|
|
quote String
|
|
at DateTime
|
|
rate Decimal @db.Decimal(18, 6)
|
|
|
|
@@unique([base, quote, at])
|
|
@@index([base, quote])
|
|
}
|