Skip to content

Relax namespace_id presence checks in GitlabSubscriptions::AddOnPurchase

What does this MR do and why?

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/420313+

Prior to this change, the namespace_id was required for a GitlabSubscriptions::AddOnPurchase. This is because the first iteration of it was for SaaS only. With an upcoming iteration, support for SM is added and the add-on purchase logic will be handled slightly different. This is because SM will look for an add-on purchase on an instance level and not namespace level.

This change updates the presence validation on the namespace_id attribute in the GitlabSubscriptions::AddOnPurchase model to only trigger if we're on GitLab.com. The association to a namespace will also be optional when we're not on GitLab.com. Additionally, the not null condition on the namespace_id database column is update to allow null values.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports