Skip to content

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

Revert "Remove old JSONField from cart"

Krzysztof Wolskia0c427bf31dc
diff --git a/saleor/cart/migrations/0006_auto_20161209_0750.py b/saleor/cart/migrations/0006_auto_20161209_0750.py
deleted file mode 100644
index 75c558edf1..0000000000
--- a/saleor/cart/migrations/0006_auto_20161209_0750.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.10.3 on 2016-12-09 13:50
-from __future__ import unicode_literals
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('cart', '0005_migrate_json_data'),
- ]
-
- operations = [
- migrations.AlterUniqueTogether(
- name='cartline',
- unique_together=set([('cart', 'variant', 'data_postgres')]),
- ),
- migrations.RemoveField(
- model_name='cart',
- name='checkout_data',
- ),
- migrations.RemoveField(
- model_name='cartline',
- name='data',
- ),
- ]
diff --git a/saleor/cart/models.py b/saleor/cart/models.py
index cec916e6c0..0dbdbab54b 100644
--- a/saleor/cart/models.py
+++ b/saleor/cart/models.py
@@ -12,8 +12,9 @@ from django.utils.encoding import python_2_unicode_compatible, smart_str
from django.utils.timezone import now
from django.utils.translation import pgettext_lazy
from django_prices.models import PriceField
-from django.contrib.postgres.fields import JSONField
-from satchless.item import ItemLine, ItemList, partition
+from django.contrib.postgres.fields import JSONField as postgres_JSONField
+from jsonfield import JSONField
+from satchless.item import ItemLine, ItemSet, ItemList, partition
from ..discount.models import Voucher
from ..product.models import ProductVariant
@@ -100,7 +101,8 @@ class Cart(models.Model):
primary_key=True, default=uuid4, editable=False)
voucher = models.ForeignKey(
Voucher, null=True, related_name='+', on_delete=models.SET_NULL)
- checkout_data_postgres = JSONField(null=True, editable=False)
+ checkout_data = JSONField(null=True, editable=False)
+ checkout_data_postgres = postgres_JSONField(null=True, editable=False)
total = PriceField(
currency=settings.DEFAULT_CURRENCY, max_digits=12, decimal_places=2,
@@ -228,10 +230,11 @@ class CartLine(models.Model, ItemLine):
quantity = models.PositiveIntegerField(
pgettext_lazy('Cart line', 'quantity'),
validators=[MinValueValidator(0), MaxValueValidator(999)])
- data_postgres = JSONField(blank=True, default={})
+ data = JSONField(blank=True, default={})
+ data_postgres = postgres_JSONField(blank=True, default={})
class Meta:
- unique_together = ('cart', 'variant', 'data_postgres')
+ unique_together = ('cart', 'variant', 'data')
def __str__(self):
return smart_str(self.variant)