Skip to content

Fix/589 db transactions - #619

Merged
Abdulazeem-code merged 7 commits into
Abdulazeem-code:mainfrom
Peolite1:fix/589-db-transactions
Sep 3, 2026
Merged

Fix/589 db transactions#619
Abdulazeem-code merged 7 commits into
Abdulazeem-code:mainfrom
Peolite1:fix/589-db-transactions

Conversation

@Peolite1

Copy link
Copy Markdown
Contributor

Implement database transaction wrapping for multi-step mutations

Closes #589

Description

This PR implements database transaction wrapping for endpoints that perform multi-step database mutations to ensure atomic operations and prevent partial state corruption on failure.

Previously, several endpoints (such as those handling user creation and cache invalidation, or webhook creation) ran operations in sequence without transaction wrapping. If an exception occurred midway, it left the system with partial or inconsistent data.

Changes Made

  • prismaClient.js: Added a new withTransaction utility wrapper to provide a consistent abstraction over prisma.$transaction. Also updated the mock database $transaction to support Prisma's interactive transaction format.
  • Registration Endpoint (src/routes/v1/userRoutes.js): Wrapped user creation and cache invalidation inside the transaction utility.
  • Admin Block Endpoint (src/routes/v1/adminRoutes.js): Wrapped prisma.user.update and the subsequent stats/federation cache invalidation inside the transaction utility.
  • Webhook Creation (src/routes/v1/webhookRoutes.js): Wrapped webhook creation inside the transaction utility.

Acceptance Criteria Met

  • Registration endpoint uses transaction for user creation + cache invalidation
  • Webhook creation uses transaction
  • Admin block endpoint uses transaction
  • Rollback functionality is implicitly tested by Prisma's core behavior on transaction failure

Impact

Prevents data corruption from partial writes during database, logic, or network failures.

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Peolite1 is attempting to deploy a commit to the Abdulazeem's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Peolite1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Abdulazeem-code

Copy link
Copy Markdown
Owner

FIX FAILED CHECKS AND RESOLVE CONFLICTS

@Peolite1

Peolite1 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

FIX FAILED CHECKS AND RESOLVE CONFLICTS

done

@Abdulazeem-code

Copy link
Copy Markdown
Owner

FIX FAILED CHECKS

@Abdulazeem-code

Copy link
Copy Markdown
Owner

FIX FAILED CHECKS

@Peolite1

Peolite1 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

FIX FAILED CHECKS

done

@Abdulazeem-code
Abdulazeem-code merged commit 9513669 into Abdulazeem-code:main Sep 3, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement database transaction wrapping for multi-step mutations

2 participants