Wednesday, May 6, 2015

Stale contenttype

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3XaRkgkxMZWD4eDFSpp4q%2B3e%3D6etSroPxYH%2Bt%2B8_5cpvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment