MySQL 版本控制 - Subversion

2021-12-24 00:00:00 workflow svn mysql version-control

想知道是否可以对 MySQL 数据库进行版本控制.

Wondering if it is possible to have a version control of a MySQL database.

我意识到之前有人问过这个问题,但最新的已经是一年前了,而且事情正在发生变化......

I realize this question has been asked before however the newest is almost a year ago, and at the rate things change...

问题来了,每个开发人员在他们自己的计算机上都有 apache/MySQL/PHP,他们有时会在其中编辑数据库.如果他们必须向所有其他开发人员发送电子邮件,然后手动编辑测试服务器数据库,则相当不方便.

The problem is coming that each developer has apache/MySQL/PHP on their own computers to which they sometimes edit the database. Its rather inconvenient if they have to send an email to all the other developers and then manually edit the test servers database.

你是如何处理这个问题的?

How do you deal with this problem?

谢谢

推荐答案

这本身并不是一个与 MySQL 相关的解决方案,但我们在名为 liquibase 的产品上取得了很多成功.(http://www.liquibase.org/)

This is not a MySQL-related solution in itself, but we've had a lot of success with a product called liquibase. (http://www.liquibase.org/)

这是一个涵盖许多不同数据库供应商的迁移解决方案,允许将所有数据库更改编码在配置文件中,所有这些都保存在 Subversion 中.由于所有配置都保存在 XML 文件中,因此很容易将其他人的更改合并到主线脚本中,并且可以很好地与标签和分支配合使用.

It's a migration solution which covers many different database vendors, allowing all database changes to be coded in configuration files, all of which are kept in Subversion. Since all configuration is kept in XML files, it's easy to merge other people's changes into the mainline script and it plays well with tags and branches.

可以通过运行更新数据库"命令将数据库提升到当前修订级别.大多数更改还具有回滚数据库更改的能力,这也很有帮助.我建议遵循以下做法:确保在运行迁移之前获得最新信息,因为这可能是最简单的.

The database can be brought up to the current revision level by running the "update database" command. Most changes also have the ability to roll-back a database change, which can be helpful too. I would recommend following the practice of making sure you get current before running the migration, as this would likely be easiest.

最后,当涉及到生产交付时,您可以选择将所有数据库更改输出为完整的 SQL 脚本,以便 DBA 可以运行它并保持职责分离.

Finally, when it comes to a production delivery, you can choose to have all the database changes output as a full SQL script so it can allow DBAs to run it and maintain a separation of duties.

到目前为止,它的效果非常好.

So far, it's worked like a charm.

相关文章