diff --git a/CHANGELOG.md b/CHANGELOG.md index 596a34e60c..89be8869d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved the colors of the muted texts and borders by enabling the dark mode of `bootstrap` - Reduced the size of the global stylesheet by removing the unused utilities of `bootstrap` - Hardened the validation of the date in the endpoint to create an account balance +- Added `userId` to the unique constraint of the `AccountBalance` database schema - Upgraded `bootstrap` from version `4.6.2` to `5.3.8` ### Fixed diff --git a/apps/api/src/app/account-balance/account-balance.service.ts b/apps/api/src/app/account-balance/account-balance.service.ts index 56975cdf08..afa4386e01 100644 --- a/apps/api/src/app/account-balance/account-balance.service.ts +++ b/apps/api/src/app/account-balance/account-balance.service.ts @@ -68,9 +68,9 @@ export class AccountBalanceService { value: balance }, where: { - userId, - accountId_date: { + accountId_userId_date: { accountId, + userId, date: resetHours(parseISO(date)) } } diff --git a/prisma/migrations/20261014000000_added_user_id_to_unique_constraint_of_account_balance/migration.sql b/prisma/migrations/20261014000000_added_user_id_to_unique_constraint_of_account_balance/migration.sql new file mode 100644 index 0000000000..40c76e5816 --- /dev/null +++ b/prisma/migrations/20261014000000_added_user_id_to_unique_constraint_of_account_balance/migration.sql @@ -0,0 +1,5 @@ +-- DropIndex +DROP INDEX "AccountBalance_accountId_date_key"; + +-- CreateIndex +CREATE UNIQUE INDEX "AccountBalance_accountId_userId_date_key" ON "AccountBalance"("accountId", "userId", "date"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e21fc10e8c..17a2d4e39d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -65,7 +65,7 @@ model AccountBalance { userId String value Float - @@unique([accountId, date]) + @@unique([accountId, userId, date]) @@index([accountId]) @@index([date]) }