Ecommerce Plugin Error: Duplicate Entry '1' for key 'default_site_id'

We ran into a similar problem when we migrated from Native Koa to Tutor Koa. In fact, the problem occurred when we then migrated from Tutor Koa to Tutor Lilac.

I generally agree with @regis and I would not recommend to CHANGE SITE IDs. Unfortunately we did after a very careful reverse engineering of the ecommerce database under Native and under Tutor.

In the end, it worked for us, but I would not recommend doing it the way we did it.

It was a three steps process.

First, editing the ecommerce dump file from Koa Native to remove some tables for which we wanted to use the values generated by the default Tutor installation.

Second, restoring our new ecommerce dump in Tutor.

Third, running a script that would switch in multiple tables the values of site_id from 1 to 2 and values of partner_id from 1 to 2. That’s because our values where the reverse of what was created by Tutor in both the django_site and partner_partner tables. Our django_site for dev was 2 and for prod it was 1. The same for partner_partner. This might differ for you since you have id 4 and id 5 in your django_site table. I am guessing that id 2 and id 3 where created at some point in the past from a previous installation under Native.

We could share what we did, but we do not feel comfortable making it public because every migration could be different and the values to change could also be different.

You would need to analyze the content of your database in order for it to make sense for your own installation.