Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finwise-miniapp-be
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ThinhNC
finwise-miniapp-be
Commits
253f5929
Commit
253f5929
authored
Jul 28, 2026
by
ThinhNC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(prisma): improve wallet management schema
parent
85e41667
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
31 deletions
+56
-31
schema.prisma
prisma/schema.prisma
+56
-31
No files found.
prisma/schema.prisma
View file @
253f5929
...
...
@@ -27,7 +27,7 @@ model User {
updatedAt
DateTime
@
updatedAt
@
map
(
"updated_at"
)
//
Relations
role
Role
@
relation
(
fields
:
[
roleId
],
references
:
[
id
],
onDelete
:
Cascade
)
role
Role
@
relation
(
fields
:
[
roleId
],
references
:
[
id
],
onDelete
:
Restrict
)
wallets
Wallet
[]
categories
Category
[]
transactions
Transaction
[]
...
...
@@ -38,6 +38,7 @@ model User {
passwordResetTokens
PasswordResetToken
[]
devices
UserDevice
[]
@@
index
([
roleId
])
@@
map
(
"users"
)
}
...
...
@@ -55,7 +56,13 @@ model Wallet {
id
String
@
id
@
default
(
uuid
())
@
db
.
Uuid
userId
String
@
map
(
"user_id"
)
@
db
.
Uuid
name
String
balance
Float
balance
Decimal
@
default
(
0
)
@
db
.
Decimal
(
18
,
2
)
currency
String
@
default
(
"VND"
)
@
db
.
VarChar
(
3
)
icon
String
?
color
String
?
description
String
?
isDefault
Boolean
@
default
(
false
)
@
map
(
"is_default"
)
isArchived
Boolean
@
default
(
false
)
@
map
(
"is_archived"
)
createdAt
DateTime
@
default
(
now
())
@
map
(
"created_at"
)
updatedAt
DateTime
@
updatedAt
@
map
(
"updated_at"
)
...
...
@@ -63,22 +70,30 @@ model Wallet {
transactions
Transaction
[]
@@
unique
([
userId
,
name
])
@@
index
([
userId
])
@@
map
(
"wallets"
)
}
model
Category
{
id
String
@
id
@
default
(
uuid
())
@
db
.
Uuid
userId
String
@
map
(
"user_id"
)
@
db
.
Uuid
parentId
String
?
@
map
(
"parent_id"
)
@
db
.
Uuid
name
String
type
TransactionType
icon
String
?
color
String
?
createdAt
DateTime
@
default
(
now
())
@
map
(
"created_at"
)
updatedAt
DateTime
@
updatedAt
@
map
(
"updated_at"
)
user
User
@
relation
(
fields
:
[
userId
],
references
:
[
id
],
onDelete
:
Cascade
)
parent
Category
?
@
relation
(
"CategoryHierarchy"
,
fields
:
[
parentId
],
references
:
[
id
],
onDelete
:
SetNull
)
children
Category
[]
@
relation
(
"CategoryHierarchy"
)
transactions
Transaction
[]
budgets
Budget
[]
@@
unique
([
userId
,
name
,
type
])
@@
index
([
userId
])
@@
index
([
parentId
])
@@
map
(
"categories"
)
}
...
...
@@ -87,17 +102,25 @@ model Transaction {
userId
String
@
map
(
"user_id"
)
@
db
.
Uuid
walletId
String
@
map
(
"wallet_id"
)
@
db
.
Uuid
categoryId
String
@
map
(
"category_id"
)
@
db
.
Uuid
amount
Float
amount
Decimal
@
db
.
Decimal
(
18
,
2
)
type
TransactionType
description
String
?
receiptUrl
String
?
@
map
(
"receipt_url"
)
location
String
?
date
DateTime
createdAt
DateTime
@
default
(
now
())
@
map
(
"created_at"
)
updatedAt
DateTime
@
updatedAt
@
map
(
"updated_at"
)
user
User
@
relation
(
fields
:
[
userId
],
references
:
[
id
],
onDelete
:
Cascade
)
wallet
Wallet
@
relation
(
fields
:
[
walletId
],
references
:
[
id
],
onDelete
:
Cascade
)
wallet
Wallet
@
relation
(
fields
:
[
walletId
],
references
:
[
id
],
onDelete
:
Restrict
)
category
Category
@
relation
(
fields
:
[
categoryId
],
references
:
[
id
],
onDelete
:
Restrict
)
@@
index
([
userId
])
@@
index
([
walletId
])
@@
index
([
categoryId
])
@@
index
([
date
])
@@
index
([
userId
,
date
])
@@
index
([
userId
,
type
])
@@
map
(
"transactions"
)
}
...
...
@@ -105,16 +128,17 @@ model Budget {
id
String
@
id
@
default
(
uuid
())
@
db
.
Uuid
userId
String
@
map
(
"user_id"
)
@
db
.
Uuid
categoryId
String
@
map
(
"category_id"
)
@
db
.
Uuid
name
String
amount
Float
amount
Decimal
@
db
.
Decimal
(
18
,
2
)
startDate
DateTime
@
map
(
"start_date"
)
endDate
DateTime
@
map
(
"end_date"
)
createdAt
DateTime
@
default
(
now
())
@
map
(
"created_at"
)
updatedAt
DateTime
@
updatedAt
@
map
(
"updated_at"
)
user
User
@
relation
(
fields
:
[
userId
],
references
:
[
id
],
onDelete
:
Cascade
)
category
Category
@
relation
(
fields
:
[
categoryId
],
references
:
[
id
],
onDelete
:
Cascade
)
category
Category
@
relation
(
fields
:
[
categoryId
],
references
:
[
id
],
onDelete
:
Restrict
)
@@
index
([
categoryId
])
@@
index
([
userId
,
startDate
,
endDate
])
@@
map
(
"budgets"
)
}
...
...
@@ -143,6 +167,7 @@ model UserSocial {
user
User
@
relation
(
fields
:
[
userId
],
references
:
[
id
],
onDelete
:
Cascade
)
@@
unique
([
provider
,
providerUserId
])
@@
index
([
userId
])
@@
map
(
"user_socials"
)
}
...
...
@@ -155,6 +180,7 @@ model VerificationToken {
user
User
@
relation
(
fields
:
[
userId
],
references
:
[
id
],
onDelete
:
Cascade
)
@@
index
([
userId
])
@@
map
(
"verification_tokens"
)
}
...
...
@@ -167,6 +193,7 @@ model PasswordResetToken {
user
User
@
relation
(
fields
:
[
userId
],
references
:
[
id
],
onDelete
:
Cascade
)
@@
index
([
userId
])
@@
map
(
"password_reset_tokens"
)
}
...
...
@@ -184,5 +211,3 @@ model UserDevice {
@@
unique
([
userId
,
deviceHash
])
@@
map
(
"user_devices"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment