Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24135 closed Bug (fixed)

migrations.RenameModel does not rename m2m tables

Reported by: Ruben Nielsen Owned by: Tim Graham
Component: Migrations Version: 1.7
Severity: Release blocker Keywords: rename m2m
Cc: 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

Observe the following models

class Tag(Model):
    content = Charfield(...)

class CustomerModel(Model):
    keywords = ManyToManyField('Tag')

this will generate 3 tables

applabel_customermodel
applabel_tag
applabel_customermodel_keywords

when I try to rename CustomerModel to Customer in a migration, the autogenerated table is not renamed

migration:

operations = [
        migrations.RenameModel('CustomerModel', 'Customer'),
    ]

tables:

applabel_customer
applabel_tag
applabel_customermodel_keywords

This causes my code to fail, since lookups on customer.keywords.all() expect to find the table applabel_customer_keywords, which does not exist.

The error is observed in 1.7.1 and 1.7.2

Change History (7)

comment:1 by Simon Charette, 10 years ago

Triage Stage: UnreviewedAccepted

Managed to reproduce against master. Should this block the release of 1.8 alpha?

comment:2 by Tim Graham, 10 years ago

Type: UncategorizedBug

I presume it's an existing bug on 1.7 as well, in which case no.

comment:3 by Tim Graham, 10 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned

comment:4 by Tim Graham, 10 years ago

Has patch: set

comment:5 by Simon Charette, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 28db4af80a319485c0da724d692e2f8396aa57e3:

Fixed #24135 -- Made RenameModel rename many-to-many tables.

Thanks Simon and Markus for reviews.

comment:7 by Tim Graham <timograham@…>, 10 years ago

In 065b2a82f6d7539032e15308351fa5eee95c0cb9:

[1.7.x] Fixed #24135 -- Made RenameModel rename many-to-many tables.

Thanks Simon and Markus for reviews.

Backport of 28db4af80a319485c0da724d692e2f8396aa57e3 from master

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