Skip to content

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

Add cart lines data migration

Artur Smęt83e051d35d41
diff --git a/saleor/cart/migrations/fix_empty_data_in_lines.py b/saleor/cart/migrations/fix_empty_data_in_lines.py
new file mode 100644
index 0000000000..7b0c33e2e5
--- /dev/null
+++ b/saleor/cart/migrations/fix_empty_data_in_lines.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.3 on 2016-12-06 13:02
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+def convert_lines_data(apps, schema_editor):
+ CartLine = apps.get_model('cart', 'CartLine')
+ # Iterate over all cart lines, due to wrong JSONField None handling
+ for line in CartLine.objects.all():
+ if line.data is None:
+ line.data = {}
+ line.save(update_fields=['data'])
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('cart', '0002_auto_20161014_1221'),
+ ]
+
+ operations = [
+ migrations.RunPython(convert_lines_data)
+ ]