#34333: Django migrations adds constraint before adding field
-------------------------------------+-------------------------------------
Reporter: Raphael | Owner: nobody
Beekmann |
Type: Bug | Status: new
Component: | Version: 4.1
Migrations | Keywords: migration,
Severity: Normal | constraint, field
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hello,
I have a model, already created through previous migrations, and in a new
migration I added a new field with a UniqueConstraint.
The model looks like this (the new field is 'type') :
{{{
class Model(models.Model):
name = models.CharField()
date = models.DateField()
type = models.ForeignKey(OtherModel)
class Meta:
constraints = (
models.UniqueConstraint(fields=('date', 'type'),
name='unique_date_for_type'),
)
}}}
When I run the makemigrations script it adds first the constraint and then
the new field. That occurs an error when executing the migration :
{{{
django.core.exceptions.FieldDoesNotExist: DailyTask has no field named
'type'
}}}
I have to manually move the adds of the constraint before the adds of the
new field in the migration file to make it work.
--
Ticket URL: <https://code.djangoproject.com/ticket/34333>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018646fea6b1-c72127e8-ae58-4169-b01f-4e0d12c22815-000000%40eu-central-1.amazonses.com.