﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31185	fields.E310-E311 should take into account UniqueConstraints without conditions.	Pavel Garkin	Ahmad Abdallah	"Hello, 

I'm trying to create migration with this kind of model.

{{{
class AppUsers(models.Model):
    name = models.CharField(...)
    uid = models.CharField(...)
    source = models.ForeignKey(...)

    class Meta:
        constraints = [models.UniqueConstraint(fields=['uid', 'source'], name='appusers_uniqueness')]
}}}

When I start ''makemigrations'' command in manage.py I've faced fields.E310 [https://docs.djangoproject.com/en/2.2/ref/checks/#related-fields] error 

It says that I should add unique_together field in Meta options:
**app_name.AppUsers.field: (fields.E310) No subset of the fields 'uid', 'source' on model 'AppUsers' is unique.
HINT: Add unique=True on any of those fields or add at least a subset of them to a unique_together constraint.**

If I change Meta options to unique_together constraint migration passes with no errors.


{{{
class AppUsers(models.Model):
    name = models.CharField(...)
    uid = models.CharField(...)
    source = models.ForeignKey(...)

    class Meta:
        unique_together = [['uid', 'source']]
}}}


As mentioned in docs [https://docs.djangoproject.com/en/2.2/ref/models/options/#unique-together] ''unique_together'' may be deprecated in the future. So I think nobody wants to face this issue when this will be deprecated :) 

Thanks,
Pavel
"	Bug	closed	Core (System checks)	dev	Normal	fixed	UniqueConstraint unique_together E310 E311		Ready for checkin	1	0	0	0	1	0
