Multi-account billing schema

  • Add column to plan_log for parent_customer_id
  • CHECK trigger that plan_log inserts with a non-NULL parent use the same plan_name as parent
  • customer_plans view should include the parent
  • balance view joins customer_plans and gets balance from parent if parent exists else same as now
  • INSERT BEFORE trigger on transactions checks if the customer id has a parent and inserts to that instead if so
  • TrustLevelRepo checks if customer has a parent and gets trust level for that customer instead if so

When parent is NOTIFY to bill, probably check and bill children.

LowBalance.for(customer) should detect if customer has a parent and use that instead

This CHECK is both hard and doesn’t keep the data consistent over time. We discussed in MUC to trust the data model on this point for now.