Adds db indices
This commit is contained in:
parent
53413388e0
commit
dba3773636
2 changed files with 72 additions and 4 deletions
49
registrasion/migrations/0012_auto_20160406_1212.py
Normal file
49
registrasion/migrations/0012_auto_20160406_1212.py
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.2 on 2016-04-06 12:12
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('registrasion', '0011_auto_20160401_0943'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cart',
|
||||||
|
name='active',
|
||||||
|
field=models.BooleanField(db_index=True, default=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cart',
|
||||||
|
name='released',
|
||||||
|
field=models.BooleanField(db_index=True, default=False),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cart',
|
||||||
|
name='time_last_updated',
|
||||||
|
field=models.DateTimeField(db_index=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='category',
|
||||||
|
name='order',
|
||||||
|
field=models.PositiveIntegerField(db_index=True, verbose_name='Display order'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='product',
|
||||||
|
name='order',
|
||||||
|
field=models.PositiveIntegerField(db_index=True, verbose_name='Display order'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='productitem',
|
||||||
|
name='quantity',
|
||||||
|
field=models.PositiveIntegerField(db_index=True),
|
||||||
|
),
|
||||||
|
migrations.AlterIndexTogether(
|
||||||
|
name='cart',
|
||||||
|
index_together=set([('active', 'released'), ('released', 'user'), ('active', 'user'), ('active', 'time_last_updated')]),
|
||||||
|
),
|
||||||
|
]
|
|
@ -99,6 +99,7 @@ class Category(models.Model):
|
||||||
)
|
)
|
||||||
order = models.PositiveIntegerField(
|
order = models.PositiveIntegerField(
|
||||||
verbose_name=("Display order"),
|
verbose_name=("Display order"),
|
||||||
|
db_index=True,
|
||||||
)
|
)
|
||||||
render_type = models.IntegerField(
|
render_type = models.IntegerField(
|
||||||
choices=CATEGORY_RENDER_TYPES,
|
choices=CATEGORY_RENDER_TYPES,
|
||||||
|
@ -147,6 +148,7 @@ class Product(models.Model):
|
||||||
)
|
)
|
||||||
order = models.PositiveIntegerField(
|
order = models.PositiveIntegerField(
|
||||||
verbose_name=("Display order"),
|
verbose_name=("Display order"),
|
||||||
|
db_index=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,6 +315,7 @@ class VoucherDiscount(DiscountBase):
|
||||||
Voucher,
|
Voucher,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
verbose_name=_("Voucher"),
|
verbose_name=_("Voucher"),
|
||||||
|
db_index=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -458,17 +461,33 @@ class Cart(models.Model):
|
||||||
''' Represents a set of product items that have been purchased, or are
|
''' Represents a set of product items that have been purchased, or are
|
||||||
pending purchase. '''
|
pending purchase. '''
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
index_together = [
|
||||||
|
("active", "time_last_updated"),
|
||||||
|
("active", "released"),
|
||||||
|
("active", "user"),
|
||||||
|
("released", "user"),
|
||||||
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%d rev #%d" % (self.id, self.revision)
|
return "%d rev #%d" % (self.id, self.revision)
|
||||||
|
|
||||||
user = models.ForeignKey(User)
|
user = models.ForeignKey(User)
|
||||||
# ProductItems (foreign key)
|
# ProductItems (foreign key)
|
||||||
vouchers = models.ManyToManyField(Voucher, blank=True)
|
vouchers = models.ManyToManyField(Voucher, blank=True)
|
||||||
time_last_updated = models.DateTimeField()
|
time_last_updated = models.DateTimeField(
|
||||||
|
db_index=True,
|
||||||
|
)
|
||||||
reservation_duration = models.DurationField()
|
reservation_duration = models.DurationField()
|
||||||
revision = models.PositiveIntegerField(default=1)
|
revision = models.PositiveIntegerField(default=1)
|
||||||
active = models.BooleanField(default=True)
|
active = models.BooleanField(
|
||||||
released = models.BooleanField(default=False) # Refunds etc
|
default=True,
|
||||||
|
db_index=True,
|
||||||
|
)
|
||||||
|
released = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
db_index=True
|
||||||
|
) # Refunds etc
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def reserved_carts(cls):
|
def reserved_carts(cls):
|
||||||
|
@ -492,7 +511,7 @@ class ProductItem(models.Model):
|
||||||
|
|
||||||
cart = models.ForeignKey(Cart)
|
cart = models.ForeignKey(Cart)
|
||||||
product = models.ForeignKey(Product)
|
product = models.ForeignKey(Product)
|
||||||
quantity = models.PositiveIntegerField()
|
quantity = models.PositiveIntegerField(db_index=True)
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
|
|
Loading…
Reference in a new issue