Skip to content
  • Corinna Gogolok's avatar
    Remove active scope in add-on purchase lookup for SM · 2504d2fc
    Corinna Gogolok authored
    Prior to this change, when there was an existing add-on purchase record
    (`GitlabSubscriptions::AddOnPurchase`) for the SM instance (`namespace`
    is `nil`) and that record is expired, the license data sync would fail.
    This was because the record can't be found because the lookup for the
    add-on purchase was looking for a not expired record by using the
    `active` scope. As a result a new add-on purchase record was attempted
    to be created which would then fail due to the uniqueness validation of
    the `subscription_add_on_id` scoped to `namespace_id`.
    
    In this change, the `active` record is removed to allow finding the
    add-on purchase record and updating it regardless of being active or
    expired.
    
    Changelog: fixed
    EE: true
    2504d2fc