Opened 7 years ago
Closed 7 years ago
#28573 closed Bug (duplicate)
Migrations create a bad index if creating and renaming the same foreign key in one migration
Reported by: | Jerome Leclanche | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I have the following monster migration:
Putting aside most of it; when running it, I was getting the following error:
django.db.utils.ProgrammingError: column "customer_from_source_id" does not exist
That was very confusing, but when debugging it I found out that it's choking all the way at the end on the following sql statement:
CREATE INDEX "djstripe_card_customer_from_source_id_2343e200" ON "djstripe_card" ("customer_from_source_id")
Now, that's weird because it shouldn't be creating that index on "customer_from_source_id" but on "customer_id" instead. The field is first created like so:
migrations.AddField( model_name="card", name="customer_from_source", field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name="sources", to="djstripe.Customer"), ),
Then, it is renamed:
migrations.RenameField( model_name="card", old_name="customer_from_source", new_name="customer", ),
Change History (3)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Description: | modified (diff) |
---|
comment:3 by , 7 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Type: | Uncategorized → Bug |
This looks like a duplicate of #25530 which is fixed in Django 2.0. Can you test there and if your problem isn't fixed, reopen the ticket and include a minimal project that reproduces the problem? Thanks.
Could you try to provide a more minimal project/migration to reproduce the issue?