Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics Model Administration What are Models?

What is difference between 'makemigrations' and 'migrate' ?

What is difference between 'makemigrations' and 'migrate'? Can any one help?

2 Answers

Josip Dorvak
Josip Dorvak
18,126 Points

makemigration will create the migration. A migration basically tells your database how it's being changed(i.e new column added, new table, dropped tables etc.). migrate is what pushes your changes to your database. It will run all the migrations created(or the ones that haven't been pushed yet). Hope this helps :)

Someone else asked this, and here is Moderator Chris Freeman's answer:

"It is necessary to run both the commands to complete the migration of the database tables to be in sync with your models.

makemigrations simply analyzes your current models for any changes that would be out of sync with your database and creates a migrations file that can be used to bring the in sync. If left at this point, your models would still be out of sync with your database possibly breaking your code that queries the database.

migrate is the command to "Make It So!" and apply the changes noted during the makemigrations phase.

Applying [app] to either of these commands simply adds focus to that "app" and doesn't inspect all of your apps."

Rui Xu
Rui Xu
11,245 Points

Thanks for posting it here. :)