Skip to content
This repository was archived by the owner on Jul 17, 2018. It is now read-only.

ProgrammingError: relation "django_content_type" does not exist #53

Open
andreav opened this issue Feb 6, 2016 · 2 comments
Open

ProgrammingError: relation "django_content_type" does not exist #53

andreav opened this issue Feb 6, 2016 · 2 comments

Comments

@andreav
Copy link

andreav commented Feb 6, 2016

Hi,
I just migrated to django 1.8

My operations are:

  1. scratch whole db
  2. remove all migartions from my apps
  3. manage.py makemigrations
  4. manage.py migrate

However I get this error after "manage.py migrate" command:

django.db.utils.ProgrammingError: relation "django_content_type" does not exist

The sql command causing the error is:

u'ALTER TABLE "djangoratings_vote" ADD CONSTRAINT "djan_content_type_id_34170de97babd8e2_fk_django_content_type_id" FOREIGN KEY ("content_type_id") REFERENCES "django_content_type" ("id") DEFERRABLE INITIALLY DEFERRED'

If a comment out djangoratings from INSTALLED_APPS, the migrations finishes without problems.

If I issue a "./manage.py showmigrations" I get empty migrations for django ratings.

contenttypes
 [ ] 0001_initial
 [ ] 0002_remove_content_type_name
djangoratings
 (no migrations)                     <------------ strange this
guardian
 [ ] 0001_initial

The exception is raised when running deferred SQL.

Creating tables...
    Creating table thumbnail_kvstore
    Creating table djangoratings_vote
    Creating table djangoratings_score
    Creating table djangoratings_similaruser
    Creating table djangoratings_ignoredobject
    Running deferred SQL...
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
    ........

I will continue investigating but maybe you know/have a solution.

Thank you.

@andreav
Copy link
Author

andreav commented Feb 6, 2016

I just tried the same commands with django 1.9 and the migration successfully terminates!

However at the moment I cannot update to Django1.9 due to lack of support from other applications, so I'm still looking for a solution.

@andreav
Copy link
Author

andreav commented Feb 6, 2016

At the moment I can get the complete migration splitting the migration by steps:

./manage.py migrate contenttypes
./manage.py migrate auth
./manage.py migrate sites
./manage.py migrate my_custom_auth_app
./manage.py migrate

and this will complete my migrations.

I got errors during migration but everything seems to work in the end.

By the way, I could not run just:
manage.py migrate contenttypes && manage.py migrate
because contenttypes depends on auth_permission, but auth_permission depends on sites, and sites depends on my_custom_auth_app (maybe related to https://code.djangoproject.com/ticket/24075 but I'm not sure)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant