3

I have been developing a Django project using sqlite3 as the backend and it has been working well. I am now attempting to switch the project over to use postgres as the backend but running into some issues.

After modifying my settings file, setting up postgres, creating the database and user I get the error below when running manage.py migrate

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

financemgr is an app within the project. rate is a table within the app.

If I run this same command but specify sqlite3 as my backend it works fine.

For clarity I will repeat:

Environment Config1

  • Ubuntu 14.04, Django 1.10
  • Settings file has 'ENGINE': 'django.db.backends.sqlite3'
    1. Run manage.py migrate
    2. Migration runs and processes all the migrations successfully

Environment Config2

  • Ubuntu 14.04, Django 1.10
  • Settings file has 'ENGINE': 'django.db.backends.postgresql_psycopg2'
    1. Run manage.py migrate
    2. Migration runs and gives the error django.db.utils.ProgrammingError: relation "financemgr_rate" does not exist

Everything else is identical. I am not trying to migrate data, just populate the schema etc.

Any ideas?

4
  • do you have such a model (called Rate?) Commented Oct 6, 2016 at 6:13
  • I think you have pre-stored migration files(migrate for sqlite database) , now you have change the database configuration but still django looking for the existing table according to migration files you have. Better you delete all the migration files in migration folder in your app, and migrate it again, it may work fine. Commented Oct 6, 2016 at 10:51
  • Hi @PiyushS.Wanare , yes you are correct. I had to delete the old migration files and it worked. Would you like to put that in an answer and then I can accept it? Commented Oct 17, 2016 at 18:12
  • Yup Thanks @James Commented Oct 18, 2016 at 5:40

1 Answer 1

3

This may help you :

I think you have pre-stored migration files(migrate for sqlite database). Now you have change the database configuration but still django looking for the existing table according to migration files you have(migrated for previous database). Better you delete all the migration files in migration folder of your app, and migrate it again, by running commands python manage.py makemigrations and python manage.py migrate it may work fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.