Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#31326 closed Uncategorized (invalid)

Deleting a concrete subclass table with no additional fields results results in invalid migration

Reported by: Stephen Finucane Owned by: nobody
Component: Uncategorized 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

Take the following models

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:

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")

Change History (2)

comment:1 by Simon Charette, 5 years ago

Resolution: invalid
Status: newclosed

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).

comment:2 by Stephen Finucane, 5 years ago

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

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