Add billing_account_id to CloudActivation

Problem

The CloudActivation model currently has an association with an individual Customer (to be renamed User) via foreign key customer_id. This relationship is problematic for many reasons and should be associated with a BillingAccount instead.

Proposal

With the new data structure for BillingAccount and BillingAccountMembership, the CloudActivation model should be updated to be associated with an BillingAccount instead of a Customer. The full migration will need to be done in steps, spread across multiple issues and MRs.

For this issue, we will focus on getting to a compatibility mode where customer_id continues to be set, but the billing_account_id should also be set. In this issue, the following should be covered:

  • Add billing_account_id column
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5717
  • Start setting billing_account_id in application logic (e.g. when creating a CloudActivation)
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5738
  • Use new billing_account relationship instead of customer when account_data_structure feature flag is enabled
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5754
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5809
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5836
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5858
  • Introduce rake task to backfill billing_account_id for existing CloudActivation records
    • If it's easier, this could be added to the rake task from #4798 (closed). Or it could be a standalone task.
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5890

Result

billing_account_id will be populated similar to how customer_id is set currently. customer_id will continue to be populated to ensure compatibility and allow us to revert if needed. When the feature flag is enabled, the new billing_account_id will be used instead of customer_id.

Edited Nov 17, 2022 by Tyler Amos
Assignee Loading
Time tracking Loading