[Django] #31326: Deleting a concrete subclass table with no additional fields results results in invalid migration

10 views
Skip to first unread message

Django

unread,
Mar 1, 2020, 10:33:54 AM3/1/20
to django-...@googlegroups.com
#31326: Deleting a concrete subclass table with no additional fields results
results in invalid migration
--------------------------------------------+------------------------
Reporter: Stephen Finucane | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
Take the following models

{{{#!python
class Parent(models.Model):
name = models.CharField(max_length=255)

class Child(Parent):
pass
}}}

Attempting the delete `Child` will result in a migration like so:

{{{#!python
from django.db import migrations

class Migration(migrations.Migration):
dependencies = []

operations = [
migrations.RemoveField(
model_name='child',
name='parent_ptr',
),
migrations.DeleteModel(
name='Child',
),
]
}}}

Unfortunately this results in an error from PostgreSQL at least:

{{{
django.db.utils.OperationalError: (1090, "You can't delete all columns
with ALTER TABLE; use DROP TABLE instead")
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31326>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 1, 2020, 11:52:22 AM3/1/20
to django-...@googlegroups.com
#31326: Deleting a concrete subclass table with no additional fields results
results in invalid migration
----------------------------------+--------------------------------------

Reporter: Stephen Finucane | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.11
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Simon Charette):

* status: new => closed
* resolution: => invalid


Comment:

You reported this issue on Django 1.11 but it cannot be reproduced anymore
in Django 2.2+ (likely because of
ad82900ad94ed4bbad050b9993373dafbe66b610).

It can also be easily worked around by removing the `RemoveField`
operation entirely.

Closing this ticket as invalid because the patch won't be backported to
1.11 (it only receives security backport at this point).

--
Ticket URL: <https://code.djangoproject.com/ticket/31326#comment:1>

Django

unread,
Mar 2, 2020, 9:23:00 AM3/2/20
to django-...@googlegroups.com
#31326: Deleting a concrete subclass table with no additional fields results
results in invalid migration
----------------------------------+--------------------------------------

Reporter: Stephen Finucane | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.11
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by Stephen Finucane):

Dropping the errant line is indeed what I did. Apologies for not testing
this on a newer version.

--
Ticket URL: <https://code.djangoproject.com/ticket/31326#comment:2>

Reply all
Reply to author
Forward
0 new messages