Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix failing order migrations (#9426)
Iga Karbowiak6d8c3599b16d
diff --git a/saleor/account/migrations/0063_save_customerevent_order_token.py b/saleor/account/migrations/0063_save_customerevent_order_token.pyindex 6978cf08f9..0843c2f0e4 100644--- a/saleor/account/migrations/0063_save_customerevent_order_token.py+++ b/saleor/account/migrations/0063_save_customerevent_order_token.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0127_add_order_number_and_alter_order_token"),+ ("order", "0129_alter_order_number"),("account", "0062_alter_user_updated_at"),]diff --git a/saleor/account/migrations/0064_rewrite_customerevent_order_relation.py b/saleor/account/migrations/0064_rewrite_customerevent_order_relation.pyindex 2082a32514..482109cb2e 100644--- a/saleor/account/migrations/0064_rewrite_customerevent_order_relation.py+++ b/saleor/account/migrations/0064_rewrite_customerevent_order_relation.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0129_change_pk_to_uuid"),+ ("order", "0131_change_pk_to_uuid"),("account", "0063_save_customerevent_order_token"),]diff --git a/saleor/discount/migrations/0037_rewrite_discount_order_relations.py b/saleor/discount/migrations/0037_rewrite_discount_order_relations.pyindex 67f75a9d85..0c14a53679 100644--- a/saleor/discount/migrations/0037_rewrite_discount_order_relations.py+++ b/saleor/discount/migrations/0037_rewrite_discount_order_relations.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0129_change_pk_to_uuid"),+ ("order", "0131_change_pk_to_uuid"),("discount", "0036_save_discocunt_order_token"),]diff --git a/saleor/giftcard/migrations/0013_giftcardevent_order.py b/saleor/giftcard/migrations/0013_giftcardevent_order.pyindex ffae241c39..bc825bbf7b 100644--- a/saleor/giftcard/migrations/0013_giftcardevent_order.py+++ b/saleor/giftcard/migrations/0013_giftcardevent_order.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0133_alter_order_options"),+ ("order", "0135_alter_order_options"),("giftcard", "0012_auto_20211007_0655"),]diff --git a/saleor/invoice/migrations/0007_save_invoice_order_token.py b/saleor/invoice/migrations/0007_save_invoice_order_token.pyindex 1e55c2dc35..6d10c83ee8 100644--- a/saleor/invoice/migrations/0007_save_invoice_order_token.py+++ b/saleor/invoice/migrations/0007_save_invoice_order_token.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0127_add_order_number_and_alter_order_token"),+ ("order", "0129_alter_order_number"),("invoice", "0006_invoiceevent_app"),]diff --git a/saleor/invoice/migrations/0008_rewrite_invoice_order_relations.py b/saleor/invoice/migrations/0008_rewrite_invoice_order_relations.pyindex adfc45710d..fb9fc8112c 100644--- a/saleor/invoice/migrations/0008_rewrite_invoice_order_relations.py+++ b/saleor/invoice/migrations/0008_rewrite_invoice_order_relations.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0129_change_pk_to_uuid"),+ ("order", "0131_change_pk_to_uuid"),("invoice", "0007_save_invoice_order_token"),]diff --git a/saleor/order/migrations/0127_add_order_number_and_alter_order_token.py b/saleor/order/migrations/0127_add_order_number_and_alter_order_token.pyindex fc3f2d73a0..1cd7cba424 100644--- a/saleor/order/migrations/0127_add_order_number_and_alter_order_token.py+++ b/saleor/order/migrations/0127_add_order_number_and_alter_order_token.py@@ -2,14 +2,6 @@import uuidfrom django.db import migrations, models-from django.db.models import F--import saleor.order.models---def set_order_number(apps, schema_editor):- Order = apps.get_model("order", "Order")- Order.objects.all().update(number=F("id"), use_old_id=True)class Migration(migrations.Migration):@@ -34,28 +26,4 @@ class Migration(migrations.Migration):name="number",field=models.IntegerField(blank=True, null=True),),- migrations.RunPython(set_order_number, reverse_code=migrations.RunPython.noop),- migrations.AlterField(- model_name="order",- name="number",- field=models.IntegerField(unique=True),- ),- # define auto incrementing for order number field- migrations.RunSQL(- """- CREATE SEQUENCE order_order_number_seq OWNED BY order_order.number;-- SELECT setval('order_order_number_seq', coalesce(max(number), 0) + 1, false)- FROM order_order;- """- ),- migrations.AlterField(- model_name="order",- name="number",- field=models.IntegerField(- default=saleor.order.models.get_order_number,- editable=False,- unique=True,- ),- ),]diff --git a/saleor/order/migrations/0128_set_order_number.py b/saleor/order/migrations/0128_set_order_number.pynew file mode 100644index 0000000000..b836d697fc--- /dev/null+++ b/saleor/order/migrations/0128_set_order_number.py@@ -0,0 +1,20 @@+# Generated by Django 3.2.12 on 2022-03-29 12:24++from django.db import migrations+from django.db.models import F+++def set_order_number(apps, schema_editor):+ Order = apps.get_model("order", "Order")+ Order.objects.all().update(number=F("id"), use_old_id=True)+++class Migration(migrations.Migration):++ dependencies = [+ ("order", "0127_add_order_number_and_alter_order_token"),+ ]++ operations = [+ migrations.RunPython(set_order_number, reverse_code=migrations.RunPython.noop),+ ]diff --git a/saleor/order/migrations/0129_alter_order_number.py b/saleor/order/migrations/0129_alter_order_number.pynew file mode 100644index 0000000000..85c3c16643--- /dev/null+++ b/saleor/order/migrations/0129_alter_order_number.py@@ -0,0 +1,38 @@+# Generated by Django 3.2.12 on 2022-03-29 12:31++from django.db import migrations, models++import saleor.order.models+++class Migration(migrations.Migration):++ dependencies = [+ ("order", "0128_set_order_number"),+ ]++ operations = [+ migrations.AlterField(+ model_name="order",+ name="number",+ field=models.IntegerField(unique=True),+ ),+ # define auto incrementing for order number field+ migrations.RunSQL(+ """+ CREATE SEQUENCE order_order_number_seq OWNED BY order_order.number;++ SELECT setval('order_order_number_seq', coalesce(max(number), 0) + 1, false)+ FROM order_order;+ """+ ),+ migrations.AlterField(+ model_name="order",+ name="number",+ field=models.IntegerField(+ default=saleor.order.models.get_order_number,+ editable=False,+ unique=True,+ ),+ ),+ ]diff --git a/saleor/order/migrations/0128_save_order_token_in_relation_models.py b/saleor/order/migrations/0130_save_order_token_in_relation_models.pysimilarity index 98%rename from saleor/order/migrations/0128_save_order_token_in_relation_models.pyrename to saleor/order/migrations/0130_save_order_token_in_relation_models.pyindex 339000b7cc..96a6145440 100644--- a/saleor/order/migrations/0128_save_order_token_in_relation_models.py+++ b/saleor/order/migrations/0130_save_order_token_in_relation_models.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0127_add_order_number_and_alter_order_token"),+ ("order", "0129_alter_order_number"),]operations = [diff --git a/saleor/order/migrations/0129_change_pk_to_uuid.py b/saleor/order/migrations/0131_change_pk_to_uuid.pysimilarity index 94%rename from saleor/order/migrations/0129_change_pk_to_uuid.pyrename to saleor/order/migrations/0131_change_pk_to_uuid.pyindex 4b076c5b06..7cb533a0cc 100644--- a/saleor/order/migrations/0129_change_pk_to_uuid.py+++ b/saleor/order/migrations/0131_change_pk_to_uuid.py@@ -8,7 +8,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0128_save_order_token_in_relation_models"),+ ("order", "0130_save_order_token_in_relation_models"),("account", "0063_save_customerevent_order_token"),("discount", "0036_save_discocunt_order_token"),("invoice", "0007_save_invoice_order_token"),diff --git a/saleor/order/migrations/0130_rewrite_order_relations.py b/saleor/order/migrations/0132_rewrite_order_relations.pysimilarity index 98%rename from saleor/order/migrations/0130_rewrite_order_relations.pyrename to saleor/order/migrations/0132_rewrite_order_relations.pyindex fd28010978..25292cbbe6 100644--- a/saleor/order/migrations/0130_rewrite_order_relations.py+++ b/saleor/order/migrations/0132_rewrite_order_relations.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0129_change_pk_to_uuid"),+ ("order", "0131_change_pk_to_uuid"),]operations = [diff --git a/saleor/order/migrations/0131_rename_order_token_id.py b/saleor/order/migrations/0133_rename_order_token_id.pysimilarity index 91%rename from saleor/order/migrations/0131_rename_order_token_id.pyrename to saleor/order/migrations/0133_rename_order_token_id.pyindex ca26a633bf..41b9c43f71 100644--- a/saleor/order/migrations/0131_rename_order_token_id.py+++ b/saleor/order/migrations/0133_rename_order_token_id.py@@ -6,7 +6,7 @@ from django.db import migrationsclass Migration(migrations.Migration):dependencies = [- ("order", "0130_rewrite_order_relations"),+ ("order", "0132_rewrite_order_relations"),]operations = [diff --git a/saleor/order/migrations/0132_rewrite_order_gift_cards_relation.py b/saleor/order/migrations/0134_rewrite_order_gift_cards_relation.pysimilarity index 96%rename from saleor/order/migrations/0132_rewrite_order_gift_cards_relation.pyrename to saleor/order/migrations/0134_rewrite_order_gift_cards_relation.pyindex 28c0d8bcab..a99c4349a1 100644--- a/saleor/order/migrations/0132_rewrite_order_gift_cards_relation.py+++ b/saleor/order/migrations/0134_rewrite_order_gift_cards_relation.py@@ -6,7 +6,7 @@ from django.db import migrationsclass Migration(migrations.Migration):dependencies = [- ("order", "0131_rename_order_token_id"),+ ("order", "0133_rename_order_token_id"),]operations = [diff --git a/saleor/order/migrations/0133_alter_order_options.py b/saleor/order/migrations/0135_alter_order_options.pysimilarity index 86%rename from saleor/order/migrations/0133_alter_order_options.pyrename to saleor/order/migrations/0135_alter_order_options.pyindex d33f514e89..2192e610b2 100644--- a/saleor/order/migrations/0133_alter_order_options.py+++ b/saleor/order/migrations/0135_alter_order_options.py@@ -6,7 +6,7 @@ from django.db import migrationsclass Migration(migrations.Migration):dependencies = [- ("order", "0132_rewrite_order_gift_cards_relation"),+ ("order", "0134_rewrite_order_gift_cards_relation"),]operations = [diff --git a/saleor/payment/migrations/0032_save_payment_order_token.py b/saleor/payment/migrations/0032_save_payment_order_token.pyindex 0e815c3d44..92bf6cb80a 100644--- a/saleor/payment/migrations/0032_save_payment_order_token.py+++ b/saleor/payment/migrations/0032_save_payment_order_token.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0127_add_order_number_and_alter_order_token"),+ ("order", "0129_alter_order_number"),("payment", "0031_merge_0030_auto_20210908_1346_0030_payment_partial"),]diff --git a/saleor/payment/migrations/0033_rewrite_payment_order_relations.py b/saleor/payment/migrations/0033_rewrite_payment_order_relations.pyindex 22e76d5b42..3d320b8575 100644--- a/saleor/payment/migrations/0033_rewrite_payment_order_relations.py+++ b/saleor/payment/migrations/0033_rewrite_payment_order_relations.py@@ -7,7 +7,7 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):dependencies = [- ("order", "0129_change_pk_to_uuid"),+ ("order", "0131_change_pk_to_uuid"),("payment", "0032_save_payment_order_token"),]