Before January 1.6, Django only supported adding new models to the database, but could not edit or modify existing models. At that time, the missing functions of Django could be implemented through south.
According to the official documentation, PostgreSQL databases are the best supported, followed by MySQL. Currently, SQLite cannot implement the complete migration function.
1. New commands
Django 1.7 brings us three new commands:
Migrate: used to execute migration actions
Makemigrations: Creates a new migration policy file based on the current model.
Sqlmigrate: displays the migrated SQL statement
It is worth noting that the migration is based on the app. Therefore, we can disable the migration function for some apps.
2. How to Use
The use of migrations is very simple: Modify the model, such as adding a field, and then run
python manager.py makemigrations
Your Mmodel will be scanned and compared with the previous version. The migration file will be generated in the migrations directory of the app.
We recommend that you check the migration file to make sure there is no problem. Then run:
python manager.py migrate
The migrate command will compare and apply the migration.
3. From south to new Django migrations
To upgrade from south to the latest Django migration, follow these steps:
Make sure all migration in south is applied.
Remove south from installed_apps
Delete all files in the migration directory of each app except _ init _. py
Run Python manager. py makemigrations. Django will initialize migration
Run Python manager. py migrate. Django will find that the database is the same as the initialized migration, and mark them as applied
Use of new Django 1.7 data migration tool (migrations) and how to upgrade and convert from south