• Fares's avatar
    fix(subscriptions): prevent duplicate subscription rows with unique constraint · 5a5aba46
    Fares authored
    Root causes of duplicate members in yearly subscriptions:
    1. No DB-level unique constraint allowed race conditions between
       SubscriptionGenerator, SyncService, and RetroactiveMembershipService
    2. SyncService set person_id=NULL for member rows vs Generator's person_id=memberId
    3. RetroactiveMembershipService did blind INSERTs with no dedup check
    
    Fix:
    - Migration removes existing duplicates (keeps paid row, lowest ID tiebreak)
    - Normalizes NULL person_id on member rows
    - Adds UNIQUE INDEX (member_id, financial_year, person_type, person_id)
    - All insert paths catch Duplicate entry exceptions as race guard
    - SyncService now sets person_id=memberId matching Generator
    - RetroactiveMembershipService checks for existing row before INSERT
    Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    5a5aba46
Name
Last commit
Last update
..
Controllers Loading commit data...
Models Loading commit data...
Services Loading commit data...
Views Loading commit data...
ApiRoutes.php Loading commit data...
Routes.php Loading commit data...
bootstrap.php Loading commit data...