Skip to content

PM-4892: reinforce assignment history uniqueness migration#16

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

PM-4892: reinforce assignment history uniqueness migration#16
jmgasper merged 1 commit intodevelopfrom
PM-4892-2

Conversation

@jmgasper
Copy link
Copy Markdown
Contributor

What was broken

QA still saw a Prisma unique-conflict error when reassigning the same member to a private engagement after the earlier assignment was completed.

The prior service planner fix was correct for terminal assignments, but a QA branch or environment can still retain the old broad engagement/member unique index and reject the new history row.

Root cause

The database uniqueness shape must allow multiple historical rows for the same engagement and member while still enforcing one active assignment.

When the stale broad unique index remains, creating the new selected assignment after a completed or terminated assignment fails before the service can return the expected updated engagement.

What was changed

Added a follow-up migration that defensively drops the old broad EngagementAssignment engagementId/memberId unique index.

The migration also re-creates the non-unique lookup index and the active-only unique index for SELECTED and ASSIGNED assignments.

Any added/updated tests

No new tests were added because the 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.

Validation

  • 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 a Prisma unique-conflict error when reassigning the same member to a private engagement after the earlier assignment was completed.
The prior service planner fix was correct for terminal assignments, but a QA branch or environment can still retain the old broad engagement/member unique index and reject the new history row.

Root cause
The database uniqueness shape must allow multiple historical rows for the same engagement and member while still enforcing one active assignment.
When the stale broad unique index remains, creating the new selected assignment after a completed or terminated assignment fails before the service can return the expected updated engagement.

What was changed
Added a follow-up migration that defensively drops the old broad EngagementAssignment engagementId/memberId unique index.
The migration also re-creates the non-unique lookup index and the active-only unique index for SELECTED and ASSIGNED assignments.

Any added/updated tests
No new tests were added because the 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 89613ac 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