Backfill BillingAccounts and BillingAccountMemberships for existing Customers

Problem

Once BillingAccount and BillingAccountMembership records are being created (introduced in #4795 (closed) and #4796 (closed)) and kept in sync (introduced in #4797 (closed)), we should be in a position to confidently backfill this data for existing Customer (to be renamed User) records.

Proposal

Create a rake task to backfill BillingAccount and BillingAccountMembership records for existing Customer (to be renamed User) records. We should consider an idempotent rake task that can be run multiple times. We may need to run this several times as we test out the issues for creating BillingAccounts and keeping the information in sync.

This task will need to be run at least once before the feature flag, account_data_structure, is enabled to ensure we can confidently start using the new data architecture in production. Steps have been added to the feature flag rollout issue, [Feature flag] Enables Zuora Billing Account ba... (#4867 - closed), to run the rake task introduced in this issue in non-production, then production environments. As part of this issue, we should verify the rake task works by running it in staging and production to test, but we will run it again as part of the feature flag rollout. Please update the rollout issue with the exact rake task command to run in staging and production.

Question to consider:

  • What happens when the zuora_account_id and salesforce_account_id aren't consistent between Customer (to be renamed User) records associated to the same BillingAccount? We should probably run a query to see how prevalent this is. If this does happen, how prevalent is it and can we account for these discrepancies programmatically?
Edited Oct 14, 2022 by Tyler Amos
Assignee Loading
Time tracking Loading