Implementes TODO in payments-service.ts. convert user admission to postgres stored function - #428
Conversation
phoenix-server
commented
Apr 10, 2026
There was a problem hiding this comment.
Pull request overview
Refactors the invoice-confirmation “user admission” workflow to use a PostgreSQL stored function (admit_user) instead of performing an application-layer upsert, centralizing the mutation in the database under serializable transaction guarantees.
Changes:
- Replaced the inline
userRepository.upsert(...)admission logic inPaymentsService.confirmInvoicewithuserRepository.admitUser(...). - Added
IUserRepository.admitUserand implemented it via a raw call to the new DB function. - Introduced a Knex migration that creates the
admit_userPostgreSQL function usingINSERT ... ON CONFLICT DO UPDATE.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/services/payments-service.ts | Switches invoice-confirmation admission step from upsert to stored-function call. |
| src/repositories/user-repository.ts | Adds admitUser repository method that invokes admit_user via Knex raw. |
| src/@types/repositories.ts | Extends IUserRepository interface with admitUser. |
| migrations/20260409201624_admit_user_func.js | Adds migration creating the admit_user PL/pgSQL function for atomic admission upsert. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
cameri
commented
Apr 10, 2026
You will need to rebase to fix your commit messages otherwise commitlint will fail. |
Thanks for pointing this out! I wasn’t aware that Conventional Commits was enforced in this repository. |
ff631b6 to
dfe65ccComparedfe65cc to
0861163CompareMohit-Davar
commented
Apr 11, 2026
@cameri I’ve updated all my commits to follow the repository’s commit message conventions and rebased the branch. |
refactor(db): convert user admission to postgres stored function
Description
This PR refactors the user admission workflow by introducing a PostgreSQL stored function to replace the application-layer
upsertduring the invoice confirmation flow.admit_userdatabase function, utilizing atomicON CONFLICT DO UPDATEconstraints and preservingASSERT_SERIALIZED()transaction guarantees.admitUserinterface and DB implementations logically grouping this SQL call inUserRepository.Related Issue
Resolves TODO in payments-service.ts
Motivation and Context
This completes an explicit
TODOwithin the codebase. Offloading the user admission mutation to a PostgreSQL stored function strengthens the concurrency model .How Has This Been Tested?
Verified existing repository tests pass correctly locally.
Screenshots (if appropriate):
Types of changes
Checklist: