如何像 Ruby on Rails 迁移一样迁移 Django 模型?

发布于 2024-07-20 12:30:42 字数 568 浏览 7 评论 0原文

Django 有许多开源项目,可以解决该框架更值得注意的缺少的功能之一: model "进化”。 Ruby on Rails 对迁移有本机支持,但我很好奇是否有人可以推荐以下 Django“进化”项目之一:

Django has a number of open source projects that tackle one of the framework's more notable missing features: model "evolution". Ruby on Rails has native support for migrations, but I'm curious if anyone can recommend one of the following Django "evolution" projects:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦巷 2024-07-27 12:30:42

南方的支持力度最大。 在我看来,dmigrations 太基础了。 如果你接触过 django-evolution 之外的数据库,django-evolution 就会尖叫。

南方是迄今为止最有力的竞争者。 随着模型冻结和自动迁移,它已经取得了长足的进步。

South has the most steam behind it. dmigrations is too basic IMO. django-evolution screams if you ever touch the db outside of it.

South is the strongest contender by far. With the model freezing and auto-migrations it's come a long way.

反差帅 2024-07-27 12:30:42

South 和 django-evolution 无疑是最好的选择。 根据我的经验,South 的模型冻结和自动提示仍然相当脆弱(django-evolution 的提示在边缘情况下更加强大),但 django-evolution 的开发自去年夏天以来似乎基本陷入停滞。 如果我现在开始,我可能会选择南方,主要是因为这个原因。

South and django-evolution are certainly the best options. South's model-freezing and auto-hinting are still quite fragile in my experience (django-evolution's hinting is much more robust in edge cases), but django-evolution's development seems to have mostly stalled since last summer. If I were starting now I'd probably pick South, mostly for that reason.

醉殇 2024-07-27 12:30:42

读完这篇文章后,我在不到 1 小时的时间内从“对数据模型演化一无所知”到“使用 South 来管理模型迁移”。 South 的文档非常出色,让我在创纪录的时间内加快了速度。 没有查看提到的其他工具,我完全推荐它。

更新:自从大约一个月前发布这个答案以来,我经历了几次数据模型审查,从简单的字段重命名到用新表完全替换一些表。 South 无法以完全自动化的方式完成所有操作(例如,重命名看起来像删除和添加),但文档会指导您顺利完成手动步骤。

我会将南方带入未来的任何项目中。 很棒的工具!

After reading this, I went from 'knowing nothing about data model evolution' to 'using south to manage model migration' in less than 1 hour. South's documentation is outstanding and got me up to speed in record time. Not having looked at the other tools mentioned, I fully recommend it.

Update: Since posting this answer about a month ago, I went through several data model reviews, ranging from simple field renaming to completely replacing some tables by new ones. South can not do everything in a fully automated manner (e.g. a rename looks like delete & add), but the documentation guides you smoothly through the manual steps.

I will bring south into any future project. Fantastic tool!

像你 2024-07-27 12:30:42

我是开发迁移的团队的成员 - 但我会全心全意地推荐南方。 它更加成熟,正在积极开发中,并且具有一些杀手级功能,例如 ORM 冻结(如果您尝试在迁移中使用 ORM 代码,然后更改模型,您将陷入痛苦的世界)。

I'm a member of the team that developed dmigrations - but I would wholeheartedly recommend South. It's much more mature, is under active development, and has some killer features like ORM freezing (if you try to use ORM code in dmigrations, then change your models, you're in for a world of pain).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文