Closed aiwilliams closed 7 years ago
┌───────────────────────────────┐ ┌───────────────────────────────┐
│ ┌─────────┐ │ │ ┌─────────────┐ │
│ │ Visitor │ │ │ │ Cart │ │
│┌┴─────────┴──────────────────┐│ │┌┴─────────────┴──────────────┐│
││has_many purchases◀───────┐ ││ ┌─┼▶has_many cart_items ││
││ │ ││ │ ││ ││
││first_name └──┼┼─┼─┼┤visitor_id ││
││last_name ││ │ ││tax ││
││email ││ │ ││total ││
│└─────────────────────────────┘│ │ ││purchased_at ││
└───────────────────────────────┘ │ ││stripe_charge_id ││
│ ││shipping information ││
│ │└─────────────────────────────┘│
┌───────────────────────────────┐ │ └───────────────────────────────┘
│ ┌───────────────┐ │ │
│ │ Cart Item │ │ │
│┌┴───────────────┴────────────┐│ │
││cart_id ─────────────────────┼┼─┘
││resource_type ││ ┌───────────────────────────────┐
││resource_id ─────────────────┼┼──▶│ Sermon / Sermon Series │
││quantity ││ └───────────────────────────────┘
││price ││
│└─────────────────────────────┘│
└───────────────────────────────┘
The context for Visitors is a bit tricky. Should they live in the Carts context, or the Accounts context? The more we add to them, such as Donation history, the more we'll feel like they should be in the Accounts context. But with our current model, they're tied to the Carts context.
We have decided to put Visitors in Accounts and cross contexts to reference them in Carts.