Open lpm0073 opened 2 years ago
this is addressed in https://github.com/overhangio/tutor-ecommerce/pull/27, which removes the site-id input param from ./manage.py create_or_update_site
Hi Lawrence, sorry about the delayed answer.
I think that removing the --site-id
is not an adequate solution to our problem here. The problem that we are facing is that when we pass --site-id=...
we are attempting to create multiple "Partner" objects for the same default_site_id
:
File "/openedx/ecommerce/ecommerce/core/management/commands/create_or_update_site.py", line 206, in handle
partner.save()
This is what's causing the ecommerce job to fail.
Sure, removing the --site-id
argument will resolve the error, but then we'll face another problem. Let's assume that the platform administrator changes the Ecommerce site domain: this happens very often, for instance when they switch between production/staging/local url. Then a different Site (and partner) will be created, because of the following line in create_or_update_site:
site, site_created = Site.objects.get_or_create(domain=site_domain)
Then, all existing ecommerce objects will no longer be associated to that site. This situation is a real pain to resolve for platform administrators.
I understand that you are facing this issue because you have existing data. To resolve this situation, may I suggest that you modify your existing partner codes ? for site ID 1 it should be "dev" and for site ID 2 "openedx".
Closing this for now. Feel free to re-open if the issue is still affecting you.
This is not resolved. Anyone migrating an ecommerce database from pre-tutor will be affected by this problem. i followed your suggestion above for my most recent project. that worked, thanks. however ....
this problem exists because the plugin forcefully and explicitly adds a dev site as site_id = 1, which, as one might reasonably assume, is probably going to be the existing site_id for any legacy db being migrated. your suggestion worked, but it's cumbersome and aggressive. i'd very much like to not have to repeat it for future migrations.
maybe a more graceful solution would be to make the dev site an option that's defaulted to true? i'm happy to do that work, and submit it as a PR, provided however that you're already on board with the strategy, conceptually.
I agree that hard-coding the site ID is inappropriate; unfortunately I don't have time right now to have a more in-depth look at this issue. I'll re-open this and will take some time to figure out whether removing the --site-id option is the right solution for everyone.
FTR, this same error was also reported here: https://discuss.openedx.org/t/ecommerce-plugin-error-duplicate-entry-1-for-key-default-site-id/9463
The ecommerce job does not take upgrades into consideration. In my case the ecommerce database comes from a native installation of Lilac and contains considerable transaction data that i definitely do not want to have to attempt to migrate table-by-table given the complexity of the oscar db.
openedx/ecommerce-job raises the following error: