You create datamigration:
$ python manage.py datamigration yourapp name_of_this_migration
This freezes the models in your application. If another application (s) is involved in the migration process, you need to add --freeze app1 --freeze app2 , etc. On this line to include those that are in your migration.
This sets up the basic structure of the migration files for you, but the forwards and backwards migrations are empty. It is up to you to determine the logic that will transfer data from one to another. But it works like everything else in Django, except for using South ORM. For any model of your application where this migration is located, you use orm.MyModel.objects for any other application that is added with the --freeze options, you use orm['someapp.SomeModel'].objects .
Other than that, you just get / filter / create, etc. objects as usual, moving data from one to another. Obviously, your redirected transfer requires logic that moves the data where you want, and your reverse migration must have the logic necessary to restore the data to where it was originally.
You can then move back and forth in your environment to ensure that it works properly. One important note: this is just for moving data. DO NOT modify or delete any table structures in your datamigration. If you need to delete tables after moving data. Create a migration scheme after datamigration.
source share