[Django] #24062: Reversing Model names fails!

5 views
Skip to first unread message

Django

unread,
Dec 29, 2014, 10:59:32 PM12/29/14
to django-...@googlegroups.com
#24062: Reversing Model names fails!
----------------------------+--------------------
Reporter: doepunk | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
I've run into this problem before. When I make a migration renaming a
Model and later try to revert to an older migration, it fails. The Model
is very simple with no foreign keys or other relationships to or from
other Models. It only contains one TextField and one CharacterField with
choices. When I try to migrate back after renaming the model, I get the
following error

{{{
django.db.migrations.migration.IrreversibleError: Operation <RenameModel
new_name='NewModel', old_name='OldModel'> in <migration-name> is not
reversible
}}}

I consider this a bug, because I think renaming a database table to an old
name should not result in failure.

Another thing I noticed in that context is that when I originally did the
makemigrations to the NewModel name, I was asked if I had renamed, the
OldModel, which is great. However when I ran the migrate, I was told this


{{{
The following content types are stale and need to be deleted:

<app-name> | <old-name>

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.
}}}

I'm unsure what's going on here. But shouldn't renaming involve the
automatic deletion of the old name and replacing the foreign keys with the
new database table keys? All without a need for confirmation. Or at least
if there are no foreign keys as in my case, the confirmation seems
unnecessary and it only makes it harder to run the migration unsupervised.

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

Django

unread,
Dec 30, 2014, 8:24:05 AM12/30/14
to django-...@googlegroups.com
#24062: Reversing Model names fails!
----------------------------+--------------------------------------
Reporter: doepunk | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7
Severity: Normal | Resolution: duplicate
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 timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_docs: => 0


Comment:

The model renaming request is a duplicate of #22248 which has been fixed
in the yet to be released 1.7.2.

Not sure if we can automate the renaming of content types, but we could at
least document this consideration. Please create a separate ticket,
thanks.

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

Reply all
Reply to author
Forward
0 new messages