Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Change data migration to avoid errors with non-existing OneToOne relationship

=85901fe83b59
diff --git a/saleor/site/migrations/0007_auto_20171027_0856.py b/saleor/site/migrations/0007_auto_20171027_0856.py
index e331fb3e61..a1165bf9d6 100644
--- a/saleor/site/migrations/0007_auto_20171027_0856.py
+++ b/saleor/site/migrations/0007_auto_20171027_0856.py
@@ -13,10 +13,8 @@ def link_to_sites(apps, schema_editor):
setting.site = Site.objects.get_or_create(domain=setting.domain, name=setting.name)[0]
setting.save()
- for site in Site.objects.all():
- if not site.settings:
- site.settings = SiteSettings.objects.create()
- site.save()
+ for site in Site.objects.filter(settings__isnull=True):
+ SiteSettings.objects.create(site=site, domain=site.domain, name=site.name)
class Migration(migrations.Migration):