1

There were two issues. First was due to Django converting model class name with app name prefix, and as far as that part was solved 'Relation does not exist' error after transferring to PostgreSQL I suppose it may be right to make different question.I was getting such errors as relation "blog_userprofile" does not exist and found out by

select column_name, data_type, character_maximum_length
from INFORMATION_SCHEMA.COLUMNS where table_name = 'closer';  

that there are no columns in existing database closer, so python manage.py migrate , python manage.py make migrations , python manage.py make appname, python manage.py syncdb all basically didn't works properly and didn't transform models.py into database scheme.

Why? How do I solve this ? I'v tried deleting everything from models.py and running all commands again, but it still outputs errors on nonexisting fields (?) like django.db.utils.ProgrammingError: relation "blog_community" already exists . I tried to to use --fake initial and flush and reset but neither of those helped.

Community
  • 1
  • 1
  • Don't delete models py, what you need to clear out is the content of migrations/ folder. Can you post the full model that's causing this problem. – e4c5 Dec 18 '16 at 00:40

2 Answers2

0

Basically error says you are trying to create model that was already created. Command is manage.py makemigrations to create and manage.py migrate to execute migrations. If they already exists, I guess you have done something wrong in between.
Try to delete db. Delete migrations. Create db, create migrations and run them.

Lucas03
  • 2,267
  • 2
  • 32
  • 60
0

Since you are moving from mysql to postgresql, it's safe to assume that your postgresql db does not have any data that you need.

Your current models can probably be imported directly into postgresql. However that does not mean the migration file that you have on file is compatible with postgresql.

It's very likely that your models evolved over a period of time and it's very likely that there are many old migrations files that are not compatible with postgresql.

Step 1: Go through all the apps in your project and clear out the migrations folder.

Step 2: drop the postgresql database (assuming it doesn't have any data)

Step 3: Do the following command to create migrations for django internal tables

 ./manage.py makemigrations

Step 4: Do the following command for each of your apps.

 ./manage.py makemigrations my_app_name

Step 4: Finally, do the

 ./manage.py migrate.
e4c5
  • 52,766
  • 11
  • 101
  • 134