Opened 8 years ago
Closed 8 years ago
#28493 closed Bug (fixed)
Foreign keys break on migration if models are renamed in a different app
| Reported by: | Christopher Neugebauer | Owned by: | Jeremy Satterfield |
|---|---|---|---|
| Component: | Migrations | Version: | 1.11 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Steps to reproduce:
- Create app
a, with a model calledA. Runmakemigrations a - Create app
b, with a model calledB. GiveBaForeignKeytoA. Runmakemigrations b - Rename model
AtoAa. Runmakemigrations a - 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
Change History (6)
comment:1 by , 8 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 8 years ago
| Component: | Uncategorized → Migrations |
|---|
comment:3 by , 8 years ago
comment:4 by , 8 years ago
| Has patch: | set |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
This seems to me the exact reason for the dependencies list in migrations.
comment:5 by , 8 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Type: | Uncategorized → Bug |
Pull request: https://github.com/django/django/pull/8926
Note:
See TracTickets
for help on using tickets.
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.