Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign data model for Purchases, Vouchers and Free Products #130

Closed
jonasanker opened this issue Feb 15, 2023 · 3 comments · Fixed by #190
Closed

Redesign data model for Purchases, Vouchers and Free Products #130

jonasanker opened this issue Feb 15, 2023 · 3 comments · Fixed by #190

Comments

@jonasanker
Copy link
Member

jonasanker commented Feb 15, 2023

Hi @fredpetersen
@marfavi and I discussed this. Omid's argumentation is that not all Purchases have a Payment and hence strictly speaking not a purchase. This is for instance the case with vouchers where a user is not purchasing anything but he's using a voucher which grants him Tickets. The point is that our data model is not reflecting this and it would have been best if it did. However this will require both a larger redesign and secondly a data migration. So create an issue from this and you can go ahead and merge this Pull Request. Yay 🙌🏻

Originally posted by @jonasanker in #119 (comment)

@jonasanker
Copy link
Member Author

This is a larger task and probably not something we can prioritize anytime soon.

I suggest when we pick this up we start by modelling our current database layout and from there discuss how this can be redesigned with the respect to being pragmatic so we do not put too much work on ourselves.

@jonasanker
Copy link
Member Author

Suggested data model changes

Purchases
Alter OrderId -> Only GUID values, uniqueness constraint
Alter TransactionId -> rename to ExternalTransactionId -> Null for Vouchers, Free Purchases, Incomplete Purchase. No uniqueness constraint as we can not guarantee uniqueness between more payment providers
Add PurchaseType -> Enum representing the method of fulfilling the order, i.e. MobilePayV1, MobilePayV2, Voucher, FreePurchase, Kiosk/iPad?
Vouchers
Add PurchaseId -> FK reference, nullable, to the purchase where the voucher was used
KioskPurchases? Discuss name
PurchaseId -> FK reference to Purchase
baristaInitials -> itu initials of the barista fulfilling the purchase

@jonasanker
Copy link
Member Author

Tasks for data model changes

  • Perform non-breaking data model changes (i.e. don't apply uniqueness etc yet)

Purchase-related data migrations

  • "Kiosk" purchases are migrated for both Purchases and KioskPurchase table -> References to itu initials are moved away from Purchases, TransactionId set to null, a unique Guid is created for OrderId, PurchaseType set to KioskPurchase
  • Voucher purchases are migrated in both Purchases and Vouchers tables -> PurchaseId added to Voucher entries. VoucherCode is removed from Purchases, unique OrderId is added, PurchaseType set
  • MobilePayV1, MobilePayV2 purchases will have the PurchaseType set

Clean up

  • Add breaking change table changes (i.e. uniqueness constraint)
  • Change backed to support the new flows by PurchaseType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant