Hi, firstly thanks for all your work so far on this package!
I was wondering if there is currently a way on 1.0.0 to start from scratch with dj-stripe local data. i.e. migrate on a fresh DB then sync everything from Stripe (Plans, Subs, Customers, etc)? I think there is a sync customers command..? Anything else for all other objects, or is this coming in 1.1.0 ('Master sync re-write' section in History docs)?
My issue is I'm running into migration errors (from 0.8 to 1.0.0), plus some other sync issues (e.g. deleted customers in Stripe don't fully delete in djstripe, leading to errors like AttributeError at /admin/djstripe/invoice/ 'NoneType' object has no attribute 'email'). So my plan is to remove all dj-stripe tables and just start afresh from the correct data in Stripe.
You have to do it manually at the moment but a management command would be really nice.
Something flexible like manage.py djstripe_sync all, manage.py djstripe_sync plan all, manage.py djstripe_sync plan my-plan-id...
As an aside, this would be really useful for me (I might be alone here though!). Recreating everything manually scares the hell out of me (i.e. the new idempotency key table - no idea how to populate that from current stripe data / stripe ids can't be entered in the admin - have to do on DB level..?). I do understand it's an edge case - that of a package user already having live Stripe customers, invoices, plans, subs - and wanting to use (or upgrade) dj-stripe... But would be good to have an easy way to do it like @jleclanche suggests :)
FWIW the idempotency key table is not a critical table; its contents are only valid for 24 hours anyway. What it does is it prevents race conditions when creating new customers.
The customer table is what's necessary there.
Noting my working here just in case anyone else is silly enough to want to start afresh with dj-stripe while having live Stripe data :) After some digging, the commands init_customers and sync_customers do most of the work for you. Steps below confirmed working in test mode on local development env:
Drop all dj-stripe tables
Delete all dj-stripe migrations in migrations table
Migrate
Add Stripe Plans manually to DB
Run djstripe_init_customers
Run djstripe_sync_customers (modify line 25 to get around the Cannot resolve keyword 'customer' into field error. See #497 )
fwiw my slightly bonkers plan above was more pain than it was worth. Happily, unlike on my dev DB, a straightforward migrate on the live DB worked with no issues. Lesson: Give a migration a go on a copy of your live data before making things (perhaps unnecessarily) more difficult
Most helpful comment
You have to do it manually at the moment but a management command would be really nice.
Something flexible like manage.py djstripe_sync all, manage.py djstripe_sync plan all, manage.py djstripe_sync plan my-plan-id...