edge
edge copied to clipboard
Can't make migrations using Postgres
I noticed that if I changed the database to Postgres before doing the initial migrate
, it would fail with the error
django.db.utils.ProgrammingError: relation "auth_group" does not exist
After a couple of hours I found the issue. So, I would like to suggest to add to the manual a Note that says that, if using Postgres, you need to run first:
python manage.py migrate auth
and then
python manage.py migrate
This will apply first the dependencies so that the general migration can work. If you don't run it like this, it just won't work.
Regards.
When I experienced this problem with postgreSQL I found that changing the order of mentioning the apps (in settings.py) will solve the issue. But it seems creating the auth table explicitly works in some cases.
Would mentioning this explicitly in the docs help?
Hello, this issue also took quite some time for me. @arocks How did you change the app order (what before what exactly). And I solved it using the migrate auth first, but now I run into the same problem when I use "python manage.py test" but with the testdatabase. @cesarmanzo So what should I do with the testdatabase, as I do not know if that can be configured at all... (if the order of apps solves the issue, then the testdatabase would not have the issue either I suppose...): /home/bom/.pyenv/versions/my_proj3/bin/python3.4 /opt/pycharm/helpers/pycharm/django_test_manage.py test /home/bom/my_proj3/src Testing started at 13:03 ... Creating test database for alias 'default'... Got an error creating the test database: database "test_my_projDB3" already exists
Type 'yes' if you would like to try deleting the test database 'test_my_projDB3', or 'no' to cancel: yes Destroying old test database 'default'... Traceback (most recent call last): File "/home/bom/.pyenv/versions/my_proj3/lib/python3.4/site-packages/django/db/backends/utils.py", line 62, in execute return self.cursor.execute(sql) psycopg2.ProgrammingError: relation "auth_group" does not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/pycharm/helpers/pycharm/django_test_manage.py", line 129, in
Here's a quick solution I found when facing the same problem, but first @arocks Thanks!!! You rock, this is a great project start and even with this one little issue saved my tons of time getting a prototype up and running.
First, the workaround:
python manage.py migrate auth; python manage.py migrate
works fine. Except my test runner will hit the same problem when running migrations. So I decided to do bit more research.
It turns out the authtools doesn't support django-1.7/1.8 migrations until the unreleased v1.3.0. So until we have that egg on pypy and can refer to it safely with migrations, we need to grab a solid commit from the github repo. I would update requirements/base.txt with the following lines:
#django-authtools>=1.3.0
-e git+https://github.com/fusionbox/django-authtools.git@8f040b9#egg=django-authtools
I did this and everything works smoothly :)
Hope you can roll this fix into the repo... Maybe tomorrow I can make a proper pull request.