Stale contenttype

67 views
Skip to first unread message

Timothy W. Cook

unread,
May 6, 2015, 8:42:50 AM5/6/15
to django...@googlegroups.com
Django 1.8.1, PostgreSQL 9.3, Python 3.4, Ubuntu 

I have a project that started under Django 1.4 and I have been migrating through the updates as they were published. 

At one point (I think under Django 1.5) I installed django-authtools (currently at 1.2.0)  

I am of course using Django migrations now instead of South as I was under previous Django versions.

When I do migrations now I cannot complete a migration that removes tables from my app because of this stale contentype problem. 
Other things like modifying a model work okay.  When I run migrate I get this:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Operations to perform:
  Synchronize unmigrated apps: paypal_connect, authtools, staticfiles, admindocs, messages, debug_toolbar
  Apply all migrations: sites, sessions, auth, admin, ccdgen, contenttypes
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  No migrations to apply.
The following content types are stale and need to be deleted:

    auth | user

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

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If I say I can't run the migrations on my app that delete tables.

If I say yes then I get this error. 

django.db.utils.IntegrityError: update or delete on table "auth_permission" violates foreign key constraint "auth_user_user_permissions_permission_id_fkey" on table "auth_user_user_permissions"
DETAIL:  Key (id)=(211) is still referenced from table "auth_user_user_permissions".

​BUT! the tables were actually deleted from my app.  and I do not get any warning about pending migrations. 

Now the tables that I deleted are are being shown as stale contenttypes as well.  But apparently they are all still referenced from "auth_user_user_permissions" and violate the foreign key constraint. 

So, how do I fix this?  Do I need to manually remove them from the database? 



============================================
Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

Reply all
Reply to author
Forward
0 new messages