feat: 个人记账与预算管理系统 MVP 初始版本
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
// 用户表
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
email String @unique
|
||||
createdAt DateTime @default(now())
|
||||
accounts Account[]
|
||||
budgets Budget[]
|
||||
records Record[]
|
||||
}
|
||||
|
||||
// 账户表
|
||||
model Account {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int
|
||||
name String // 账户名称(支付宝、微信、银行卡等)
|
||||
balance Decimal @default(0) // 当前余额
|
||||
type String // 账户类型
|
||||
color String // 显示颜色
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
records Record[]
|
||||
}
|
||||
|
||||
// 交易记录表
|
||||
model Record {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int
|
||||
accountId Int
|
||||
type String // 'income' | 'expense'
|
||||
amount Decimal
|
||||
category String // 消费类别
|
||||
description String? // 备注
|
||||
date DateTime
|
||||
createdAt DateTime @default(now())
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
account Account @relation(fields: [accountId], references: [id])
|
||||
}
|
||||
|
||||
// 预算表
|
||||
model Budget {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int
|
||||
category String // 预算类别
|
||||
amount Decimal // 预算金额
|
||||
month String // 预算月份(YYYY-MM)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
}
|
||||
Reference in New Issue
Block a user