您最喜欢的 django 数据库迁移管理解决方案是什么?

发布于 2024-07-11 15:59:32 字数 1542 浏览 8 评论 0原文

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

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

发布评论

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

评论(8

早茶月光 2024-07-18 15:59:32

我一直在使用South,但是迁移 看起来也很有希望。

I've been using South, but Migratory looks promising as well.

生死何惧 2024-07-18 15:59:32

Migatory 看起来既漂亮又简单。

Migratory looks nice and simple.

嘿咻 2024-07-18 15:59:32

如果您使用 SQLAlchemy 作为 ORM,那么事实上的标准是 Alembic

尚未提及的另一个替代方案是 yoyo-migrations

If you are using SQLAlchemy as your ORM then the de facto standard is Alembic.

Another alternative that haven't been mentioned is yoyo-migrations.

荒人说梦 2024-07-18 15:59:32

我们在工作中使用 Django,并且一直在使用 dmigrations。 虽然它有其怪癖,但到目前为止它很有用。 一些功能:

  • 它使用数据库中的表来跟踪已应用的迁移。
  • 因为它知道哪些已被应用,所以您可以向上和向下迁移。
  • 它作为命令与 manage.py 集成。
  • 各个迁移脚本都是 Python,但如果您的迁移逻辑是纯 SQL,那么 dmigrations 可以轻松地管理 SQL 并执行它。

一个问题是它目前只支持MySQL。 然而,我们的一个人对其进行了本地破解以支持我们使用的 PostgreSQL。 我记得,黑客攻击的范围并不是那么广泛,因此对其进行黑客攻击以支持其他 RDBMS 应该不会太困难。

We use Django at work, and we've been using dmigrations. While it has its quirks, it's been useful so far. Some features:

  • It uses a table in the database to keep track of which migrations have been applied.
  • Because it knows which ones have been applied, you can migrate up and back down.
  • It integrates with manage.py as a command.
  • The individual migration scripts are Python, but if your migration logic is pure SQL, dmigrations makes it easy to just can the SQL and have it executed.

One problem is that it only currently supports MySQL. However, one of our guys make a local hack to it to support PostgreSQL, which we use. As I recall, the hack wasn't all that extensive, so it shouldn't be terribly difficult to hack it up to support other RDBMSs.

流心雨 2024-07-18 15:59:32

我喜欢 django-evolution

优点:

  • 简洁的设计
  • ,不需要 SQL
  • ,灵活
  • ,安装简单
  • 易于使用

缺点:

  • 迁移未在代码库中修复,
  • 存在意外运行迁移两次的风险

I like django-evolution:

pros:

  • clean design
  • no SQL needed
  • flexible
  • trivial to install
  • easy to use

cons:

  • migrations are not fixed in the codebase
  • a risk exists of accidently running a migration twice
安稳善良 2024-07-18 15:59:32

除了 South、dmigrations、django-evolution 和 Migratory 我想我应该添加 simplemigrations 作为我见过的另一个用于自动化 Django 迁移的工具。

我过去使用过其中三个,但现在手动进行迁移。 由于添加了最新功能,我正在考虑再次尝试 South。

Besides South, dmigrations, django-evolution, and Migratory I thought I would add simplemigrations as another tool I've seen for automating Django migrations.

I've used three of these in the past but do migrations by hand now. I'm thinking about trying South again due to the latest features added.

腹黑女流氓 2024-07-18 15:59:32

需要注意的是,自 2009 年以来,除了 South 之外,这里提到的几乎所有项目都已经死了。 无论好坏,South 都是事实上的标准。

Just to note that since 2009, pretty much every project mentioned here other than South is dead. South is the de facto standard, for better or worse.

[旋木] 2024-07-18 15:59:32

我一直在使用 simple-db-migrate

优点:

  • 它允许我回滚迁移(如果其他人也这样做的话,我不知道)。
  • 与manage.py集成,
  • 每个了解SQL的人都可以创建迁移,
  • 它不会运行迁移两次:应用程序将迁移信息(时间戳、查询等)写入表上

缺点:

  • 如果添加具有较低时间戳的迁移与安装的最新迁移相比,此迁移不运行
  • 仅支持 MySQL

I've been using simple-db-migrate

Pros:

  • it allows me to rollback the migrations (IDK if other do this too).
  • integrates with manage.py
  • everyone that knows SQL can create a migration
  • it doesn't run a migration twice: the application writes the migration information(timestamp, query, etc.) on a table

Cons:

  • if you add a migration with a lower timestamp than the latest migration installed, this migration doesn't run
  • Only MySQL is supported
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文