Skip to content

PM-4892: drop stale assignment uniqueness constraints#17

Merged
jmgasper merged 1 commit intodevelopfrom
PM-4892-3
Apr 29, 2026
Merged

PM-4892: drop stale assignment uniqueness constraints#17
jmgasper merged 1 commit intodevelopfrom
PM-4892-3

Conversation

@jmgasper
Copy link
Copy Markdown
Contributor

What was broken

QA still saw the Prisma unique-conflict error when assigning a private engagement to a member whose previous assignment on the same engagement had been completed.

Root cause

The service planner and previous named-index migration covered the expected code path, but QA databases can still retain a broad engagement/member assignment unique constraint or index under a different generated name.

That stale uniqueness rejects the valid new assignment history row before the service can return the updated engagement.

What was changed

Added a follow-up migration that discovers and drops any unique constraint or unique index on the exact EngagementAssignment engagementId/memberId pair, regardless of name.

The migration then restores the non-unique engagement/member lookup index and recreates the intended active-only unique index for SELECTED and ASSIGNED assignments.

Any added/updated tests

No new tests were added because existing engagement service coverage already exercises same-member reassignment after COMPLETED and TERMINATED assignments.

Validation was run with lint, build, and the full Jest suite:

  • source ~/.nvm/nvm.sh && nvm use && pnpm lint
  • source ~/.nvm/nvm.sh && nvm use && pnpm build
  • source ~/.nvm/nvm.sh && nvm use && pnpm test

What was broken
QA still saw the Prisma unique-conflict error when assigning a private engagement to a member whose previous assignment on the same engagement had been completed.

Root cause
The service planner and previous named-index migration covered the expected code path, but QA databases can still retain a broad engagement/member assignment unique constraint or index under a different generated name. That stale uniqueness rejects the valid new assignment history row before the service can return the updated engagement.

What was changed
Added a follow-up migration that discovers and drops any unique constraint or unique index on the exact EngagementAssignment engagementId/memberId pair, regardless of name.

The migration then restores the non-unique engagement/member lookup index and recreates the intended active-only unique index for SELECTED and ASSIGNED assignments.

Any added/updated tests
No new tests were added because existing engagement service coverage already exercises same-member reassignment after COMPLETED and TERMINATED assignments.

Validation was run with lint, build, and the full Jest suite.
@jmgasper jmgasper merged commit 917a02f into develop Apr 29, 2026
3 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.

1 participant