Django migrations: relation does not exist

darkpool

I have a working site and database on my dev server which I am trying to setup on a live server. I am doing the following:

  • Git clone the repository from the dev server to the live server
  • Create empty database on live server (Posgres)
  • Update settings.py on the live server for all the relevant database etc settings
  • delete all migration files/folders and delete all *.pyc files
  • python manage.py makemigrations

I get the error: django.db.utils.ProgrammingError: relation "myapp_mytable" does not exist.

I can't seem to get the initial migration to happen. The only solution I have found is to go into my settings.py file and comment out all my apps within INSTALLED_APPS and go into my main urls.py file and comment out all my urls.

After commenting out those sections, I am able to do the initial migration. After that I can then uncomment my apps and start migrating them one by one, ie: python manage.py makemigrations appname then python manage.py migrate

So I have a workaround but it is far from ideal. Surely there is a way to tell django that I have created a brand new empty database so it needs to do the initial migration first. I am automating the server setup with Ansible, so requiring me to do all of this manual comment/uncomment and multiple migrations is not good.

UPDATE:

As per the comments, I am not suppose to delete the migrations. So I did the following on the dev server to try and recreate them: link. However even though I now have migration files which I have copied to the live server, when I try run them I get the same error as above.

I have read through the migration files and I don't see anything that mentions creating the initial migration / database schema. It only mentions creating my app models. I can't seem to figure out how to do the initial migration before the app migrations can be done. I need to somehow recreate all the migration files (including creating the initial db schema) from scratch so they can be run on the server.

darkpool

I eventually figured out the issue thanks to @Daniel Roseman in the comments. I was doing the following:

list(Correlation().get_entries())

What this was doing was creating a model instance (ie: Correlation) and calling the get_entries() method against that. I then surrounded that in list(). For some reason, that was stopping the migrations from working. I removed the list() which wasn't necessary anyway, and it all works now.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Django, ManyToManyField - ProgrammingError: relation foo_bar does not exist. Recognized in migrations, though relation is never created

From Dev

Django: relation does not exist

From Dev

Promise chaining in Sequelize migrations - relation does not exist

From Dev

"relation "social_auth_code" does not exist" when applying migrations on django

From Dev

"relation "social_auth_code" does not exist" when applying migrations on django

From Dev

django python - relation does not exist

From Dev

Django: Relation does not exist in Postgresql

From Dev

Django: Relation does not exist in Postgresql

From Dev

Django migrations & Heroku: ProgrammingError at / column does not exist

From Dev

Django: relation "django_site" does not exist

From Dev

Django + posgtres relation does not exist error

From Dev

ProgrammingError: relation "django_site" does not exist

From Dev

Django column "name" of relation "django_content_type" does not exist

From Dev

Relation *tablename* does not exist

From Dev

relation "old" does not exist

From Dev

Relation does not exist PLPGSQL

From Dev

Django error: relation "users_user" does not exist

From Dev

django 1.9: ProgrammingError: relation "users_user" does not exist

From Dev

relation "account_emailaddress" does not exist - django error

From Dev

executing raw sql in django error: relation does not exist

From Dev

relation "blog_blog" does not exist - error in Django app

From Dev

Django - Relation "relation" does not exist. Cannot run python manage.py migrate?

From Dev

permission denied for relation django_migrations

From Dev

Django relation error when running make migrations

From Dev

Update table - relation does not exist

From Dev

JPA ERROR: relation does not exist

From Dev

Relation does not exist error using WITH

From Dev

Django project Migration from SQL lite to postgres - relation "django_content_type" does not exist

From Dev

Django Rest Framework "django.db.utils.ProgrammingError: relation "patient" does not exist"

Related Related

  1. 1

    Django, ManyToManyField - ProgrammingError: relation foo_bar does not exist. Recognized in migrations, though relation is never created

  2. 2

    Django: relation does not exist

  3. 3

    Promise chaining in Sequelize migrations - relation does not exist

  4. 4

    "relation "social_auth_code" does not exist" when applying migrations on django

  5. 5

    "relation "social_auth_code" does not exist" when applying migrations on django

  6. 6

    django python - relation does not exist

  7. 7

    Django: Relation does not exist in Postgresql

  8. 8

    Django: Relation does not exist in Postgresql

  9. 9

    Django migrations & Heroku: ProgrammingError at / column does not exist

  10. 10

    Django: relation "django_site" does not exist

  11. 11

    Django + posgtres relation does not exist error

  12. 12

    ProgrammingError: relation "django_site" does not exist

  13. 13

    Django column "name" of relation "django_content_type" does not exist

  14. 14

    Relation *tablename* does not exist

  15. 15

    relation "old" does not exist

  16. 16

    Relation does not exist PLPGSQL

  17. 17

    Django error: relation "users_user" does not exist

  18. 18

    django 1.9: ProgrammingError: relation "users_user" does not exist

  19. 19

    relation "account_emailaddress" does not exist - django error

  20. 20

    executing raw sql in django error: relation does not exist

  21. 21

    relation "blog_blog" does not exist - error in Django app

  22. 22

    Django - Relation "relation" does not exist. Cannot run python manage.py migrate?

  23. 23

    permission denied for relation django_migrations

  24. 24

    Django relation error when running make migrations

  25. 25

    Update table - relation does not exist

  26. 26

    JPA ERROR: relation does not exist

  27. 27

    Relation does not exist error using WITH

  28. 28

    Django project Migration from SQL lite to postgres - relation "django_content_type" does not exist

  29. 29

    Django Rest Framework "django.db.utils.ProgrammingError: relation "patient" does not exist"

HotTag

Archive