What does a South datamigration do compared to a schemamigration?

点点圈 提交于 2019-12-03 13:19:24

问题


I recently began digging into the South documentation and discovered that it had two distinct types of migrations:

  • schemamigration
  • datamigration

As a result of my ignorance, I've always used schemamigrations for everything. In other words, even if I had something that was truly a "data migration", I'd simply used South's schemamigration to convert the data (with no apparent consequences).

As I read the documentation, I'm not seeing a fault in this approach. Does anyone know the fundamental difference between the two migrations and what I may be missing by sticking with schemamigrations?


回答1:


There's really only one kind of migration, but two commands. datamigration creates a new blank migration for you to fill out, while schemamigration is an optional convenience command which will attempt to detect schema changes and create a migration automatically.

Edit: from http://south.aeracode.org/docs/commands.html#schemamigration

While migrate is the real meat and bones of South, schemamigration is by comparison an entirely optional extra. It’s a utility to help write some of your migrations (specifically, the ones which change the schema) for you; if you like, you can ignore it and write everything youself, in which case we wish you good luck, and happy typing.




回答2:


Per the lead developer of South:

You can see the difference here: https://bitbucket.org/andrewgodwin/south/src/b3ed126b19a2/south/v2.py

As that shows, the only difference is that data migrations aren't dry-run if you have a database that requires it (MySQL). Otherwise, there's little difference, at least at the moment - the management commands differ, though (it's all about user interface separation, essentially).



来源:https://stackoverflow.com/questions/8358458/what-does-a-south-datamigration-do-compared-to-a-schemamigration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!