Skip to content

fix(subscriptions): prevent duplicate external_ids per organization#5558

Merged
endenis merged 4 commits into
mainfrom
fix/duplicate-external-ids-on-active-subscriptions
Jun 4, 2026
Merged

fix(subscriptions): prevent duplicate external_ids per organization#5558
endenis merged 4 commits into
mainfrom
fix/duplicate-external-ids-on-active-subscriptions

Conversation

@endenis

@endenis endenis commented May 21, 2026

Copy link
Copy Markdown
Contributor

Fixes BIL-44

Context

Multiple active subscriptions with the same external_id could coexist within the same organization for different customers.

The model validation only ran on :create missing status changes (like pending => active).

There was also no database-level unique index.

Description

In this PR:

  • Subscription model validation validate_external_id is now set to run on updates too
  • Added a service-level cross-customer check in Subscriptions::CreateService
  • Simplified the "with multuple subscriptions" tests for SubscriptionsController. They were by accident creating two active subscriptions and validations now block that
  • Did not add any unique index to the database. This should be discussed further and handled separately.

@endenis endenis self-assigned this May 21, 2026
@endenis endenis changed the title fix: stop duplicate external_ids in subscriptions fix(subscriptions): stop duplicate external_ids per organization May 21, 2026
@endenis endenis changed the title fix(subscriptions): stop duplicate external_ids per organization fix(subscriptions): prevent duplicate external_ids per organization May 21, 2026

@vincent-pochet vincent-pochet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@endenis
endenis force-pushed the fix/duplicate-external-ids-on-active-subscriptions branch from 7c25a8c to 7965013 Compare June 3, 2026 14:57
@endenis
endenis force-pushed the fix/duplicate-external-ids-on-active-subscriptions branch from 7965013 to 7690987 Compare June 3, 2026 14:59
@endenis endenis added Subscription Relation to the Subscriptions Bug labels Jun 4, 2026
@endenis
endenis merged commit 55bcd5d into main Jun 4, 2026
12 checks passed
@endenis
endenis deleted the fix/duplicate-external-ids-on-active-subscriptions branch June 4, 2026 14:43
@endenis endenis added 🐞 Bug Something isn't working and removed Bug labels Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 Bug Something isn't working Subscription Relation to the Subscriptions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants