Running migrations on Heroku and Local


#1

Hi, I’ve tried to run python manage.py migrate on my local and getting the following error:

django.db.utils.OperationalError: no such table: travel_userprofile

I also tried to run heroku run python manage.py migrate and getting a seperare error:

django.db.utils.ProgrammingError: relation "travel_place_e8701ad4" already exists

I’ve looked around, mostly on stackoverflow and haven’t found a solution. Posting here to see if anyone can help out. I’m so close to seeing my app live.


#2

Have you been able to run migrate before deploying to Heroku?

If so, can you stick your models.py code into http://pastebin.com/ and share it with me? Thanks!


#3

Hi, yes I was able to run migrate well before my deploy to heroku.

Here is the pastebin:
http://pastebin.com/S8MeX4Ln


#4

Oh, locally, did you run python manage.py makemigrations before trying to run python manage.py migrate?


#5

yes, I then run migrate and that’s when i get the following error:

django.db.utils.OperationalError: no such table: travel_userprofile

I’ve tried flushing the database and rolling back to a previous migration and nothing works.


#6

What was the output from makemigrations when you added userprofile? Basically it sounds like the migration wasn’t made when userprofile was added to your models file. Was it created recently?


#7

it creates the user profile model. But I tried removing it from models.py and running makemigrations then migrate and i still get the same error. It seems like it isn’t tied to that model specifically.


#8

Hmmm if you’ve run all of these migrations locally, the migrations themselves might be a bit messed up. They make the “plan” for your database and it might be tough to fix if the “plan” was incorrectly created. If the plan doesn’t have the correct model addition code in place, it might not create the right table, causing the error your getting.

Are you working with all test data? It might be easiest to just wipe the migrations and your database and start anew. Not your code, mind you, just your database data,