﻿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
36840	makemigrations not detecting adding UniqueConstraint to models.py	Clash City Womble	Vishy Algo	"I recently updated my Django project to use Postgres instead od SQLLite. I wanted to add some composite unique keys to a couple of tables but after adding the constraint to the model, makemigrations doesnt detect any changes. If i make any other changes to the model like adding a new field then it detects that fine, creates the migration and I can apply it no problem. I'm a bit stuck. Do I just create the constraint through running some Postgres SQL or should it be managed through the models? Any help gratefully received!


{{{
class CollectionSegment(models.Model):   
    constraints = [
        models.UniqueConstraint(
        fields=['collection', 'athletesegment'], 
        name='composite_unique_key')
        ]
    collection = models.ForeignKey(Collection, on_delete=models.CASCADE)
    athletesegment = models.ForeignKey(AthleteSegment, on_delete=models.CASCADE)
}}}
"	Uncategorized	closed	Migrations	5.1	Normal	invalid		Clash City Womble	Unreviewed	0	0	0	0	0	0
