144 lines
4.1 KiB
Plaintext
144 lines
4.1 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
output = "../node_modules/.prisma/client"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(uuid())
|
|
email String @unique
|
|
password String
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
userId String @unique
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@map("accounts")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
account Account?
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
expensesLists ExpenseList[]
|
|
incomeList IncomeList[]
|
|
bankCard BankCard[]
|
|
cash Cash[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model ExpenseList {
|
|
id String @id @default(uuid())
|
|
items ExpenseItem[]
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
title String
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("expenses_lists")
|
|
}
|
|
|
|
model ExpenseItem {
|
|
id String @id @default(uuid())
|
|
expenseList ExpenseList @relation(fields: [expenseListId], references: [id], onDelete: Cascade)
|
|
expenseListId String
|
|
title String
|
|
description String?
|
|
date DateTime
|
|
amount Float
|
|
currency String @default("RUB")
|
|
count Float @default(1)
|
|
paymentType ExpenseItemFromType? @map("payment_type")
|
|
paymentSourceId String? @map("payment_source_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("expenses_items")
|
|
}
|
|
|
|
model IncomeList {
|
|
id String @id @default(uuid())
|
|
items IncomeItem[]
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
title String
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("incomes_lists")
|
|
}
|
|
|
|
model IncomeItem {
|
|
id String @id @default(uuid())
|
|
incomeList IncomeList @relation(fields: [incomeListId], references: [id], onDelete: Cascade)
|
|
incomeListId String
|
|
title String
|
|
description String?
|
|
date DateTime
|
|
amount Float
|
|
currency String @default("RUB")
|
|
count Float @default(1)
|
|
targetType IncomeItemToType? @map("target_type")
|
|
targetSourceId String? @map("target_source_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("incomes_items")
|
|
}
|
|
|
|
model BankAccount {
|
|
id String @id @default(uuid())
|
|
balance Float @default(0)
|
|
cards BankCard[]
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("bank_accounts")
|
|
}
|
|
|
|
model BankCard {
|
|
id String @id @default(uuid())
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
name String
|
|
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id], onDelete: Cascade)
|
|
bankAccountId String
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("bank_cards")
|
|
}
|
|
|
|
model Cash {
|
|
id String @id @default(uuid())
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
name String
|
|
balance Float @default(0)
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("cash")
|
|
}
|
|
|
|
enum ExpenseItemFromType {
|
|
BANK_CARD
|
|
CASH
|
|
|
|
@@map("expense_item_from_types")
|
|
}
|
|
|
|
enum IncomeItemToType {
|
|
BANK_CARD
|
|
CASH
|
|
|
|
@@map("income_item_to_types")
|
|
}
|