Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.7 makemigrations not having an effect

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?

like image 378
Ben Avatar asked Nov 20 '14 20:11

Ben


People also ask

Why Makemigrations is not working?

This may happen due to the following reasons: You did not add the app in INSTALLED_APPS list in settings.py (You have to add either the app name or the dotted path to the subclass of AppConfig in apps.py in the app folder, depending on the version of django you are using). Refer documentation: INSTALLED_APPS.

How do I reset my Django Makemigrations?

Django's migration can be reset by cleaning all the migration files except __init__.py files under each project app directory, followed by dropping the database and creating migration again using python manage.py makemigrations and python manage.py migrate .

What is the difference between Makemigrations and migrate?

migrate , which is responsible for applying and unapplying migrations. makemigrations , which is responsible for creating new migrations based on the changes you have made to your models.


1 Answers

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

like image 112
Boris Davidov Avatar answered Sep 23 '22 06:09

Boris Davidov