I tried to make new migrations but show me error. I am using django1.9 and python 2.7 .Is any solution for this so i can create new migration.How can I do the migration?
django.db.utils.IntegrityError: could not create unique index "appointments_userappointments_advance_c37857a7_uniq"
DETAIL: Key (advance, status)=(5000, 3) is duplicated.
Here is my model:
class UserAppointments(models.Model):
"""
Represent an Appointment entity
"""
STATUS = (
("1", 'Scheduled'),
("2", 'Active'),
("3", 'Completed'),
("4", 'Cancelled')
)
customer = models.ForeignKey(Customer, null=True, blank=True)
staff_user = models.ForeignKey(StaffUser, null=True, blank=True, related_name='staff_user')
service = models.ForeignKey(Service, null=True, blank=True)
advance = models.IntegerField(default=0, null=True, blank=True)
date_time = models.DateTimeField(auto_now_add=True)
creation_date = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(StaffUser, null=True, blank=True, related_name='created_by')
update_date = models.DateTimeField(auto_now=True, null=True, blank=True)
updated_by = models.ForeignKey(StaffUser, null=True, blank=True, related_name='updated_by')
status = models.CharField(max_length=1, default=1, choices=STATUS)
class Meta:
verbose_name_plural = 'Appointments'
ordering = ['date_time']
def __unicode__(self):
return self.date_time.strftime("%Y-%m-%d %H:%M:%S")
and my migration file:
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('appointments', '0009_auto_20180114_1838'),
]
operations = [
migrations.AlterModelOptions(
name='userappointments',
options={'ordering': ['advance'], 'verbose_name_plural': 'Appointments'},
),
migrations.AlterUniqueTogether(
name='userappointments',
unique_together=set([('advance', 'status')]),
),
]