Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#22975 closed Bug (fixed)

Cannot rename model keeping db table name

Reported by: rhcarvalho Owned by: nobody
Component: Migrations Version: 1.7-rc-1
Severity: Release blocker Keywords: migrations
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django migrations do not work when you rename a model keeping the db table name. For instance:

# -- models.py --
class Book(models.Model):

name = models.CharField()
class Meta:

db_table = "books"

# -- models.py after renaming model --
class AwesomeBook(models.Model):

name = models.CharField()
class Meta:

db_table = "books"

The migration system ends up making an operational error by trying to rename the table from books to books, when the rename is unnecessary.

https://github.com/django/django/commit/fddc5957c53bd654312c4a238a8cdcfe5f4ef4cc#commitcomment-6916125

Change History (3)

comment:1 Changed 2 years ago by Florian Apolloner

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:2 Changed 2 years ago by Andrew Godwin <andrew@…>

Resolution: fixed
Status: newclosed

In dcb4ed517082d13ccf7da9bd5d16c77bcecbf139:

Fixed #22975: Don't call rename SQL if not needed

comment:3 Changed 2 years ago by Andrew Godwin <andrew@…>

In f57e84392e9aea19f8f9dc31f1e5351de356ce34:

[1.7.x] Fixed #22975: Don't call rename SQL if not needed

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