Skip to content

Conversation

julienbourdeau
Copy link
Contributor

@julienbourdeau julienbourdeau commented Jul 18, 2025

Context

Plans have Features and Privileges but it's possible to override them at the subscription level.
The tough part is that a feature can have no privilege, it can be part of the plan, but removed from the subscription. This is why we need the SubscriptionFeatureRemoval models.

Description

CleanShot 2025-06-23 at 17 32 39@2x Image

The View

In order to provide the full details of the subscriptions entitlements (plan entitlements + subscription overrides - subscription removals) we create a database view and a read only models, which allows use to query one table to get all the info.

The details are serialized as a collection (because it's one line per privilege but it needs to be grouped by feature to form the correct object.

New endpoints

api_v1_subscription_entitlement_privilege DELETE                    /api/v1/subscriptions/:subscription_external_id/entitlements/:entitlement_code/privileges/:code(.:format) api/v1/subscriptions/entitlements/privileges#destroy {code: /.*/, entitlement_code: /.*/}
   remove_api_v1_subscription_entitlement POST                      /api/v1/subscriptions/:subscription_external_id/entitlements/:code/remove(.:format)                       api/v1/subscriptions/entitlements#remove {code: /.*/}
                                          DELETE                    /api/v1/subscriptions/:subscription_external_id/entitlements/:code/remove(.:format)                       api/v1/subscriptions/entitlements#unremove {code: /.*/}
         api_v1_subscription_entitlements GET                       /api/v1/subscriptions/:subscription_external_id/entitlements(.:format)                                    api/v1/subscriptions/entitlements#index
          api_v1_subscription_entitlement PATCH                     /api/v1/subscriptions/:subscription_external_id/entitlements/:code(.:format)                              api/v1/subscriptions/entitlements#update {code: /.*/}
                                          PUT                       /api/v1/subscriptions/:subscription_external_id/entitlements/:code(.:format)                              api/v1/subscriptions/entitlements#update {code: /.*/}
                                          DELETE                    /api/v1/subscriptions/:subscription_external_id/entitlements/:code(.:format)                              api/v1/subscriptions/entitlements#destroy {code: /.*/}
                                          PATCH                     /api/v1/subscriptions/:subscription_external_id/entitlements(.:format)                                    api/v1/subscriptions/entitlements#update
                                          GET|POST|PUT|DELETE|PATCH /*unmatched(.:format)                                                                                     application#not_found

@julienbourdeau julienbourdeau self-assigned this Jul 18, 2025
@julienbourdeau julienbourdeau changed the title Feat/ent sub override feat(entitlement): Introduce subscription override Jul 18, 2025
@julienbourdeau julienbourdeau force-pushed the feat/ent-sub-override branch 3 times, most recently from 375f594 to ce537f7 Compare July 18, 2025 09:55
@julienbourdeau julienbourdeau marked this pull request as ready for review July 18, 2025 10:03
@julienbourdeau julienbourdeau force-pushed the feat/ent-sub-override branch from ce537f7 to 00eaef6 Compare July 18, 2025 10:14
@julienbourdeau julienbourdeau force-pushed the feat/ent-sub-override branch from 31c535c to b291603 Compare July 18, 2025 13:22
Copy link
Contributor

@groyoh groyoh left a comment

Choose a reason for hiding this comment

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

I haven't finished the review. Will come back on it after a break but I'm sending the comments I already have.

groyoh
groyoh previously requested changes Jul 21, 2025
Copy link
Contributor

@groyoh groyoh left a comment

Choose a reason for hiding this comment

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

Looking great, nice work! The most important feedback are the ones about DB, the rest are mostly polish.

@julienbourdeau julienbourdeau force-pushed the feat/ent-sub-override branch from ee5e1ed to ba695a2 Compare July 21, 2025 13:11
Copy link
Contributor

@groyoh groyoh left a comment

Choose a reason for hiding this comment

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

That was quite a big one 😄 Nice job!

@julienbourdeau julienbourdeau merged commit d9efef7 into main Jul 21, 2025
14 checks passed
@julienbourdeau julienbourdeau deleted the feat/ent-sub-override branch July 21, 2025 14:52
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.

2 participants