I created my models using inspectdb, it struck me odd at the time that django generated the following since there is just one such index, but i let it be
unique_together = (('p_id', 'v_id', 'sku',), ('p_id', 'v_id', 'sku',))
now i'm trying to add 'sku2' to this index and 'migrate' is failing with the following:
File "/home/user/.pyenv/versions/2.7.11/envs/master2/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 347, in _delete_composed_index
", ".join(columns),
ValueError: Found wrong number (2) of constraints for vendor_products(p_id, v_id, sku)
this is my model:
class Products(models.Model):
p_id = models.OneToOneField(MasterProducts, models.DO_NOTHING, db_column='p_id', primary_key=True)
v_id = models.ForeignKey('Sellers', models.DO_NOTHING, db_column='v_id')
sku = models.TextField()
sku2 = models.TextField(blank=True, null=True)
class Meta:
managed = True
db_table = 'products'
unique_together = (('p_id', 'v_id', 'sku',), ('p_id', 'v_id', 'sku',))
i tried changing unique_together to (('p_id', 'v_id', 'sku',),) and ('p_id', 'v_id', 'sku',) with the same result.
also i tried manually deleting the unique index using the db and recreating it using django and it still won't let me add sku2.
Why is this happening, how do i fix it?