[Django] #24546: Deletion of stale content types during migrate should show cascade

9 views
Skip to first unread message

Django

unread,
Mar 27, 2015, 10:13:24 AM3/27/15
to django-...@googlegroups.com
#24546: Deletion of stale content types during migrate should show cascade
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: nobody
Type: New | Status: new
feature |
Component: Core | Version: master
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When deleting stale content-types, the migrate command says:

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

auth | group_permissions

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

Type 'yes' to continue, or 'no' to cancel: yes
}}}

At this point, the user has no way to tell whether they should answer
'yes' or 'no'.

Usually they will type 'no' until they get bored, say a quick prayer and
type 'yes'.

----

Django contains infrastructure to determine how many objects will be
deleted.

{{{
>>> ct = ContentType.objects.get(app_label='auth',
model='group_permissions')
>>> collector = NestedObjects(using=DEFAULT_DB_ALIAS)
>>> collector.collect([ct])
>>> print(collector.nested())
[<ContentType: group-permission relationship>]
}}}

It would be helpful to display the list of objects that will be deleted or
at least the number of objects.

If the collector returns just the original object, perhaps migrate could
even proceed with the deletion without asking.

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

Django

unread,
Mar 27, 2015, 10:17:07 AM3/27/15
to django-...@googlegroups.com
#24546: Deletion of stale content types during migrate should show cascade
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by erikr):

* stage: Unreviewed => Accepted


Comment:

Yes, this would be great. I ran into this just yesterday, and indeed
answered no because I just wasn't sure enough. I'm not sure whether
automatic deletion if there are no other objects is good - somehow it
seems to me that migrate should not automatically delete such data even if
it seems harmless.

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

Django

unread,
Mar 27, 2015, 12:12:25 PM3/27/15
to django-...@googlegroups.com
#24546: Deletion of stale content types during migrate should show cascade
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

The argument for deleting automatically is that content types are created
automatically.

They're mostly a technicality of the admin's history log, not a user-
visible feature.

--
Ticket URL: <https://code.djangoproject.com/ticket/24546#comment:2>

Django

unread,
Mar 27, 2015, 12:31:16 PM3/27/15
to django-...@googlegroups.com
#24546: Deletion of stale content types during migrate should show cascade
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by carljm):

I _wish_ content types were an implementation detail (or didn't exist at
all), but unfortunately I don't think that's the case. They are a core
part of the GenericForeignKey, which is very much a user-visible feature.
And the ContentType model itself is documented as a user-visible feature,
as well, so it would be entirely reasonable for people to have cascading
FKs pointing to ContentType, and that would be within public documented
API.

--
Ticket URL: <https://code.djangoproject.com/ticket/24546#comment:3>

Django

unread,
Mar 27, 2015, 4:59:20 PM3/27/15
to django-...@googlegroups.com
#24546: Deletion of stale content types during migrate should show cascade
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

s/feature/footgun/ ;-)

In case I wasn't clear enough, I consider automatic deletion acceptable
only when there are no related objects that the cascade would delete, not
even admin log entries.

--
Ticket URL: <https://code.djangoproject.com/ticket/24546#comment:4>

Django

unread,
Mar 28, 2015, 12:42:15 PM3/28/15
to django-...@googlegroups.com
#24546: Deletion of stale content types during migrate should show cascade
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: nobody
Type: New feature | Status: closed

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* status: new => closed
* resolution: => duplicate


Comment:

Dup of #18682.

--
Ticket URL: <https://code.djangoproject.com/ticket/24546#comment:5>

Reply all
Reply to author
Forward
0 new messages