Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#24573 closed Bug (fixed)

"Unknown column" exception after removing field in migration.

Reported by: Tomasz Główka Owned by: Markus Holtermann
Component: Migrations Version: 1.8
Severity: Release blocker Keywords:
Cc: joostrijneveld@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tomasz Główka)

When removing field of base class model in my migration and than using RunPython with subclass model query I face exception django.db.utils.OperationalError: (1054, "Unknown column 'bugapp_person.name' in 'field list'"). It looks like during migrating, current migration state of submodel does not reflect field removal. Base class is alright though. Additionally, this happens only when at least one extra model with OTO field to base model exists.

This occurs in Django 1.8. I had no problem with any of 1.7.x (1.7.7 recently). Simplified snippet attached below runs smoothly with 1.7 and should reproduce the error under 1.8.

Attachments (2)

0001_inital.py (1.5 KB) - added by Tomasz Główka 4 years ago.
traceback.py (4.3 KB) - added by Tomasz Główka 4 years ago.

Download all attachments as: .zip

Change History (9)

Changed 4 years ago by Tomasz Główka

Attachment: 0001_inital.py added

Changed 4 years ago by Tomasz Główka

Attachment: traceback.py added

comment:1 Changed 4 years ago by Tomasz Główka

Description: modified (diff)

comment:2 Changed 4 years ago by Markus Holtermann

Has patch: set
Needs documentation: set
Needs tests: set
Owner: changed from nobody to Markus Holtermann
Severity: NormalRelease blocker
Status: newassigned
Triage Stage: UnreviewedAccepted

Ok, it took me a while, but I can confirm that bug.

PR: https://github.com/django/django/pull/4447

comment:3 Changed 4 years ago by Joost Rijneveld

Cc: joostrijneveld@… added

comment:4 Changed 4 years ago by Markus Holtermann

Needs documentation: unset
Needs tests: unset

I finally added a test case. Ready for review.

comment:5 Changed 4 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:6 Changed 4 years ago by Markus Holtermann <info@…>

Resolution: fixed
Status: assignedclosed

In b93690c4:

Fixed #24573 -- Considered new related models for reloading

Thanks tttomekkk for the report.

comment:7 Changed 4 years ago by Markus Holtermann <info@…>

In 0cacb8f8:

[1.8.x] Fixed #24573 -- Considered new related models for reloading

Thanks tttomekkk for the report.

Backport of b93690c4652a108b4305c0df34509bfc267fd927 from master

Note: See TracTickets for help on using tickets.
Back to Top