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 trialLogesh Jayaraman
445 PointsDifference
What is the difference between Makemigrations and migrations. i saw the notes as
"python manage.py makemigrations [app] will make the migrations for a specific app.
python manage.py migrate [app] will run the pending migrations for a specific app. If you leave off the app name, any pending migrations for any apps will be run."
Is it mandatory to run both the commands.
And what is syncdb?
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsIt 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.
syncdb
is used for newly created models that do not yet have a corresponding table in the database. This is why syncdb
is run first when you have a new models.py
file.