Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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. :)