Opened 12 months ago

Closed 12 months ago

Last modified 12 months 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 12 months ago by apollo13

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

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

  • Resolution set to fixed
  • Status changed from new to closed

In dcb4ed517082d13ccf7da9bd5d16c77bcecbf139:

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

comment:3 Changed 12 months 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