Skip to content

[Bug] Org invitations: re-invite blocked by UQ_org_email_pending including status #122

@Salem874

Description

@Salem874

Problem

tblOrgInvitations.UQ_org_email_pending (orgHandle, email, status) includes status, so only one row per lifecycle state is allowed. A second cancel/expire for the same org+email collides with the unique key, so re-invite cycles fail.

Affected

  • web/_sql/schema/014_org_invitations.sql
  • web/_functions/org.php (invite/cancel/expire flow)

Fix

Enforce "one PENDING per org+email" only — e.g. a generated column pendingKey = IF(status='pending', CONCAT(orgHandle,'|',email), NULL) with a UNIQUE key (InnoDB exempts NULLs), and drop status from the guarantee.

Acceptance criteria

  • Cancel → re-invite → cancel works repeatedly for the same org+email.
  • Still cannot have two simultaneous PENDING invites for the same org+email.

From the 2026-06-04 schema review — see docs/SCHEMA_REVIEW_2026-06-04.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomponent-AComponent A: Main Website (go2my.link)component-databaseDatabase schema, migrations, procedurespriority-highHigh priority

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions