Nathan Tregillus
Nathan Tregillus

Reputation: 6334

Deleting unused Models, stale content types prompt

I am removing an unnecessary table and model from our Django website. I have removed all foriegn key references before the migrations.DeleteModel(...) is called, but I still am receiving the following prompt when I run the migration:

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

myapp | MyDeletedModel

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

I am confused why I am receiving this prompt is there a way I can stop this prompt from showing when we go live? we use a CI environment where we do not have users available to answer "yes" or "no"

Thanks

Upvotes: 11

Views: 7063

Answers (1)

knbk
knbk

Reputation: 53679

The contenttypes framework contains references to model tables. In this case, you have a stale reference to the table you just deleted. It is perfectly safe to answer yes and remove the stale contenttype. It would be a different story if you renamed a table that had a GenericForeignKey pointing to it, in which case other objects would have a ForeignKey to that ContentType, and the delete would cascade along those relations.

In a live environment, you can pass the --noinput option to suppress this prompt. However, it will default to no. It's usually not really a problem to have some stale contenttypes lying around.

Upvotes: 14

Related Questions