1. Create app `a`, with a model called `A`. Run `makemigrations a`
2. Create app `b`, with a model called `B`. Give `B` a `ForeignKey` to
`A`. Run `makemigrations b`
3. Rename model `A` to `Aa`. Run `makemigrations a`
4. Run `migrate`
Expected behaviour:
The migration completes successfully
Actual behaviour:
Migration `0001` on `b` is run after migration `0002` on `a`, and the
migration fails with the following error:
` raise ValueError('Related model %r cannot be resolved' %
self.remote_field.model)
ValueError: Related model u'a.A' cannot be resolved`
--
Ticket URL: <https://code.djangoproject.com/ticket/28493>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> Steps to reproduce:
>
> 1. Create app `a`, with a model called `A`. Run `makemigrations a`
> 2. Create app `b`, with a model called `B`. Give `B` a `ForeignKey` to
> `A`. Run `makemigrations b`
> 3. Rename model `A` to `Aa`. Run `makemigrations a`
> 4. Run `migrate`
>
> Expected behaviour:
>
> The migration completes successfully
>
> Actual behaviour:
>
> Migration `0001` on `b` is run after migration `0002` on `a`, and the
> migration fails with the following error:
>
> ` raise ValueError('Related model %r cannot be resolved' %
> self.remote_field.model)
> ValueError: Related model u'a.A' cannot be resolved`
New description:
Steps to reproduce:
1. Create app `a`, with a model called `A`. Run `makemigrations a`
2. Create app `b`, with a model called `B`. Give `B` a `ForeignKey` to
`A`. Run `makemigrations b`
3. Rename model `A` to `Aa`. Run `makemigrations a`
4. Run `migrate`
Expected behaviour:
The migration completes successfully
Actual behaviour:
Migration `0001` on `b` is run after migration `0002` on `a`, and the
migration fails with the following error:
{{{
raise ValueError('Related model %r cannot be resolved' %
self.remote_field.model)
ValueError: Related model u'a.A' cannot be resolved
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28493#comment:1>
* component: Uncategorized => Migrations
--
Ticket URL: <https://code.djangoproject.com/ticket/28493#comment:2>
Comment (by Christopher Neugebauer):
n.b. it is possible to make these migrations work by manually adding
`run_before`, but it seems to me like this *should* be able to run
automatically.
--
Ticket URL: <https://code.djangoproject.com/ticket/28493#comment:3>
* owner: nobody => Jeremy Satterfield
* status: new => assigned
* has_patch: 0 => 1
Comment:
This seems to me the exact reason for the dependencies list in migrations.
--
Ticket URL: <https://code.djangoproject.com/ticket/28493#comment:4>
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
Pull request: https://github.com/django/django/pull/8926
--
Ticket URL: <https://code.djangoproject.com/ticket/28493#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"0891503fad458e7dfabc5adbf314f80e78e63f14" 0891503f]:
{{{
#!CommitTicketReference repository=""
revision="0891503fad458e7dfabc5adbf314f80e78e63f14"
Fixed #28493 -- Made migrations autodetector find dependencies for model
renaming.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28493#comment:6>