Migrations
Migrations help you to confidently make changes to your models. Introduced in Django 1.7, migrations are an essential and easy-to-use parts of a development workflow.
The new workflow is essentially as follows:
- The first time you define your model classes, you will need to run:
python manage.py makemigrations <app_label>
- This will create migration scripts in
app/migrations
folder. - Run the following command
i
n the same (development) environment:python manage.py migrate <app_label>
This will apply the model changes to the database. Sometimes, questions are asked to handle the default values, renaming, and so on.
- Propagate the migration scripts to other environments. Typically, your version control tool, for example Git, will take care of ...
Get Django: Web Development with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.