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
Hide 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
...
...
@@ -13,31 +13,32 @@ enum TransactionType {
}
model
User
{
id
String
@
id
@
default
(
uuid
())
@
db
.
Uuid
email
String
?
@
unique
id
String
@
id
@
default
(
uuid
())
@
db
.
Uuid
email
String
?
@
unique
password
String
?
fullName
String
?
@
map
(
"full_name"
)
avatarUrl
String
?
@
map
(
"avatar_url"
)
phoneNumber
String
?
@
unique
@
map
(
"phone_number"
)
fullName
String
?
@
map
(
"full_name"
)
avatarUrl
String
?
@
map
(
"avatar_url"
)
phoneNumber
String
?
@
unique
@
map
(
"phone_number"
)
isActive
Boolean
@
default
(
false
)
@
map
(
"is_active"
)
deletedAt
DateTime
?
@
map
(
"deleted_at"
)
deletedBy
String
?
@
map
(
"deleted_by"
)
@
db
.
Uuid
roleId
String
@
map
(
"role_id"
)
@
db
.
Uuid
createdAt
DateTime
@
default
(
now
())
@
map
(
"created_at"
)
updatedAt
DateTime
@
updatedAt
@
map
(
"updated_at"
)
createdAt
DateTime
@
default
(
now
())
@
map
(
"created_at"
)
updatedAt
DateTime
@
updatedAt
@
map
(
"updated_at"
)
//
Relations
role
Role
@
relation
(
fields
:
[
roleId
],
references
:
[
id
],
onDelete
:
Cascade
)
wallets
Wallet
[]
categories
Category
[]
transactions
Transaction
[]
budgets
Budget
[]
refreshTokens
RefreshToken
[]
socialAccounts
UserSocial
[]
verificationTokens
VerificationToken
[]
role
Role
@
relation
(
fields
:
[
roleId
],
references
:
[
id
],
onDelete
:
Restrict
)
wallets
Wallet
[]
categories
Category
[]
transactions
Transaction
[]
budgets
Budget
[]
refreshTokens
RefreshToken
[]
socialAccounts
UserSocial
[]
verificationTokens
VerificationToken
[]
passwordResetTokens
PasswordResetToken
[]
devices
UserDevice
[]
devices
UserDevice
[]
@@
index
([
roleId
])
@@
map
(
"users"
)
}
...
...
@@ -52,33 +53,47 @@ model Role {
}
model
Wallet
{
id
String
@
id
@
default
(
uuid
())
@
db
.
Uuid
userId
String
@
map
(
"user_id"
)
@
db
.
Uuid
name
String
balance
Float
createdAt
DateTime
@
default
(
now
())
@
map
(
"created_at"
)
updatedAt
DateTime
@
updatedAt
@
map
(
"updated_at"
)
id
String
@
id
@
default
(
uuid
())
@
db
.
Uuid
userId
String
@
map
(
"user_id"
)
@
db
.
Uuid
name
String
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"
)
user
User
@
relation
(
fields
:
[
userId
],
references
:
[
id
],
onDelete
:
Cascade
)
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"
)
}
...
...
@@ -136,13 +160,14 @@ model RefreshToken {
model
UserSocial
{
id
String
@
id
@
default
(
uuid
())
@
db
.
Uuid
userId
String
@
map
(
"user_id"
)
@
db
.
Uuid
provider
String
//
"ZALO"
,
"GOOGLE"
,
etc
.
provider
String
//
"ZALO"
,
"GOOGLE"
,
etc
.
providerUserId
String
@
map
(
"provider_user_id"
)
createdAt
DateTime
@
default
(
now
())
@
map
(
"created_at"
)
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"
)
}
...
...
@@ -179,10 +206,8 @@ model UserDevice {
createdAt
DateTime
@
default
(
now
())
@
map
(
"created_at"
)
lastLoginAt
DateTime
@
default
(
now
())
@
map
(
"last_login_at"
)
user
User
@
relation
(
fields
:
[
userId
],
references
:
[
id
],
onDelete
:
Cascade
)
user
User
@
relation
(
fields
:
[
userId
],
references
:
[
id
],
onDelete
:
Cascade
)
@@
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