Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix migrations failing when missing site settings (#11984)
Krzysztof Waliczek6ec971d09e6f
diff --git a/saleor/channel/migrations/0007_order_settings_per_channel.py b/saleor/channel/migrations/0007_order_settings_per_channel.pyindex 16936ef7f5..b0a62daa56 100644--- a/saleor/channel/migrations/0007_order_settings_per_channel.py+++ b/saleor/channel/migrations/0007_order_settings_per_channel.py@@ -7,13 +7,18 @@ def set_order_settings(apps, schema_editor):site_settings = SiteSettings.objects.first()- Channel.objects.update(- automatically_confirm_all_new_orders=(+ automatically_confirm_all_new_orders = True+ automatically_fulfill_non_shippable_gift_card = True+ if site_settings:+ automatically_confirm_all_new_orders = (site_settings.automatically_confirm_all_new_orders- ),- automatically_fulfill_non_shippable_gift_card=(+ )+ automatically_fulfill_non_shippable_gift_card = (site_settings.automatically_fulfill_non_shippable_gift_card- ),+ )+ Channel.objects.update(+ automatically_confirm_all_new_orders=automatically_confirm_all_new_orders,+ automatically_fulfill_non_shippable_gift_card=automatically_fulfill_non_shippable_gift_card,)diff --git a/saleor/channel/migrations/0008_update_null_order_settings.py b/saleor/channel/migrations/0008_update_null_order_settings.pyindex 1d1c49b7af..b63ed20c07 100644--- a/saleor/channel/migrations/0008_update_null_order_settings.py+++ b/saleor/channel/migrations/0008_update_null_order_settings.py@@ -14,16 +14,21 @@ def set_order_settings(apps, schema_editor):site_settings = SiteSettings.objects.first()+ automatically_confirm_all_new_orders = True+ automatically_fulfill_non_shippable_gift_card = True+ if site_settings:+ automatically_confirm_all_new_orders = (+ site_settings.automatically_confirm_all_new_orders+ )+ automatically_fulfill_non_shippable_gift_card = (+ site_settings.automatically_fulfill_non_shippable_gift_card+ )Channel.objects.filter(Q(automatically_confirm_all_new_orders__isnull=True)| Q(automatically_fulfill_non_shippable_gift_card__isnull=True)).update(- automatically_confirm_all_new_orders=(- site_settings.automatically_confirm_all_new_orders- ),- automatically_fulfill_non_shippable_gift_card=(- site_settings.automatically_fulfill_non_shippable_gift_card- ),+ automatically_confirm_all_new_orders=automatically_confirm_all_new_orders,+ automatically_fulfill_non_shippable_gift_card=automatically_fulfill_non_shippable_gift_card,)