dj-stripe / dj-stripe

dj-stripe automatically syncs your Stripe Data to your local database as pre-implemented Django Models allowing you to use the Django ORM, in your code, to work with the data making it easier and faster.
https://dj-stripe.dev
MIT License
1.56k stars 474 forks source link

Database size? Excluding models? #2002

Closed eddielu closed 6 months ago

eddielu commented 6 months ago

Hey, thanks for writing this great library. I'm really interested in integrating it inside our production app.

I was reading in the Model reference that this library stores & updates 50 different Stripe models. For folks already using this library: Does dj stripe blow up your database size? If so, are there any best practices I should be aware of (e.g. blacklisting certain models)?

Really curious how using this library has worked out in practice. Thanks!!!

jleclanche commented 6 months ago

Hi @eddielu! Thanks for considering it

Database size is a non-issue in terms of normal usage. The only table you should watch out for is the events table as this one can grow unbounded. Other than that, the tables grow alongside your customer base and payments processed.

It's worth noting almost all the tables are OK to discard and rebuild. We develop dj-stripe as a cache first and foremost, treating Stripe as the source of truth, not dj-stripe.

One thing you may want to consider (which we are currently actively working on), if you are processing a lot of events, you may not want to listen to every event type in your dj-stripe webhooks. It's safe to discard most of the events and only retain the customer and billing ones, plus whatever other types of models you want to actively use in your django code.

Hope that helps.

PS: If you're looking for help integrating dj-stripe, please reach out by email, we offer consulting and you get to support the development of the library!