Django 1.8 - what's the difference between migrate and makemigrations?

user2719875 picture user2719875 · May 1, 2015 · Viewed 24.7k times · Source

According to the documentation here: https://docs.djangoproject.com/en/1.8/topics/migrations/ it says:

migrate, which is responsible for applying migrations, as well as unapplying and listing their status.

and

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

From what I understand, I first do

makemigrations

to create the migration file and then do

migrate

to actually apply the migration?

Do note though that I just began my Django project and I added my app to my "installed_apps" list. After that, I did

python manage.py runserver

and it said

You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them.

It didn't mention anything about running makemigrations.

Answer

Hakim picture Hakim · Dec 25, 2016

According the Polls tutorial:

  1. python manage.py makemigrations <app>: Create the migrations (generate the SQL commands).

  2. python manage.py migrate: Run the migrations (execute the SQL commands).