6

I keep running python manage.py makemigrations on my heroku server, but no matter how many times I run it I get:

$heroku run python manage.py makemigrations
Running `python manage.py makemigrations` attached to terminal... up, run.2680
Migrations for 'default':
  0002_auto_20141120_2007.py:
    - Alter field user on usersocialauth

and if I run heroku run python manage.py migrate

it comes back with:

Running `python manage.py migrate` attached to terminal... up, run.1285
Operations to perform:
  Synchronize unmigrated apps: baflist_core, rest_framework, localflavor, storages
  Apply all migrations: admin, userAccount, contenttypes, sessions, default, location, messaging, forum, auth, posts
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

Admittedly, I only know enough about postgres and migrations to be dangerous, so I figured I'd ask on here. Has anyone run into this before?

Ben
  • 6,986
  • 6
  • 44
  • 71
  • You should not be running makemigrations on the server. Run it locally, add the created migration files to git, and push it, and heroku will automatically run migrate for you – Daniel Roseman Nov 20 '14 at 21:53

1 Answers1

7

After local migration completed you should have migration file(s) on <your django app>/migrations folder Ex (restapi is mine django application here):

/Django/app/folder/restapi/migrations$ ls
0001_initial.py  0001_initial.pyc  __init__.py  __init__.pyc

So you should commit migrations file manually:

heroku$ git commit restapi/migrations/0001_initial.py -m "migrations file"
heroku$ git push heroku master

Note: NO heroku will not run migrate on you app automatically! I have checked this! You should run migrate for your app after you push the file:

heroku$ heroku run python manage.py migrate restapi Running python manage.py migrate restapi attached to terminal... up, run.4602 Operations to perform: Apply all migrations: restapi Running migrations: Applying restapi.0001_initial... OK

ahmed
  • 5,430
  • 1
  • 20
  • 36
Boris Davidov
  • 294
  • 2
  • 6
  • Thank you for this answer. I was scratching my head on this issue as my settings file reflected the heroku settings and I had not yet created another dev settings file to run things locally then pushing back to heroku. +1! – John Z Mar 26 '15 at 00:42