Opened 9 years ago

Closed 9 years ago

#25036 closed New feature (duplicate)

`manage.py migrate --noinput` does not delete stale content types

Reported by: Ed Morley Owned by: nobody
Component: contrib.contenttypes Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Ticket #12339 made the check for stale content types prompt before deletion:
django/contrib/contenttypes/management.py#L60-L75

eg:

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

    model | foo

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:

I need to avoid the prompt for my deploy script (as well as local development setup scripts), so thought I could just pass --noinput to migrate.

However as can be seen at the link above, this doesn't delete the stale content types - as it's equivalent to answering 'no' at the prompt.

I think --noinput should be equivalent to entering 'yes', or else there should be a --force option - for people that know the issues with cascade deletes do not affect them.

I'm happy to open a PR - which approach would people prefer? (I'm presuming the latter, to prevent surprising people already using --noinput)

Thanks! :-)

Change History (2)

comment:1 by Ed Morley, 9 years ago

Also, when using --noinput, there isn't any console output implying that there are stale content types to be deleted. We should at least warn about it, so people using --noinput in their deploy scripts know to go back and check, when reviewing deploy logs.

comment:2 by Tim Graham, 9 years ago

Resolution: duplicate
Status: newclosed
Type: BugNew feature

How about a helper function as implemented in #24865 which can be used in your own migrations? I think it's a safer solution.

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