Context
Application creation checks for duplicates before inserting, and approval checks for an existing approved application before updating. Both are check-then-write flows, so concurrent requests can pass the checks and commit conflicting rows.
Scope
- Add a database uniqueness guarantee for one application per
(payout_id, grantee_id).
- Enforce at most one approved application per payout using an appropriate PostgreSQL constraint/index or transactional locking strategy.
- Make approval update the application and payout/grantee relationship atomically.
- Define deterministic conflict responses for concurrent create/approve requests.
- Validate that only eligible, published bounty payouts can receive applications.
- Add migration handling for any pre-existing duplicates or multiple approvals.
Acceptance criteria
Relevant areas
BountyApplication in prisma/schema.prisma and all bounty-application API routes.
Context
Application creation checks for duplicates before inserting, and approval checks for an existing approved application before updating. Both are check-then-write flows, so concurrent requests can pass the checks and commit conflicting rows.
Scope
(payout_id, grantee_id).Acceptance criteria
409, not a generic500.Relevant areas
BountyApplicationinprisma/schema.prismaand all bounty-application API routes.