简体   繁体   English

MySQL 版本控制 - Subversion

[英]MySQL Version Control - Subversion

Wondering if it is possible to have a version control of a MySQL database.想知道是否可以对 MySQL 数据库进行版本控制。

I realize this question has been asked before however the newest is almost a year ago, and at the rate things change...我意识到之前有人问过这个问题,但最新的已经是一年前了,而且事情发生了变化......

The problem is coming that each developer has apache/MySQL/PHP on their own computers to which they sometimes edit the database.问题来了,每个开发人员在他们自己的计算机上都有 apache/MySQL/PHP,他们有时会在其中编辑数据库。 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?你如何处理这个问题?

Thanks谢谢

This is not a MySQL-related solution in itself, but we've had a lot of success with a product called liquibase.这本身并不是一个与 MySQL 相关的解决方案,但我们在名为 liquibase 的产品上取得了很多成功。 ( http://www.liquibase.org/ ) ( http://www.liquibase.org/ )

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

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.我建议遵循确保在运行迁移之前获取最新信息的做法,因为这可能是最简单的。

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.最后,当涉及到生产交付时,您可以选择将所有数据库更改输出作为一个完整的 SQL 脚本,以便 DBA 可以运行它并保持职责分离。

So far, it's worked like a charm.到目前为止,它就像一个魅力。

Well we use Rails which keeps all the change in the migration files.好吧,我们使用 Rails 来保存迁移文件中的所有更改。 I know that a couple of PHP frameworks do the same thing - Symphony for instance.我知道有几个 PHP 框架做同样的事情——例如 Symphony。 So when all the changes are merged in our repository ( we user mercurial) - we can see all the changes in migrations that need to or were applied on database in development.因此,当所有更改都合并到我们的存储库中时(我们用户 mercurial) - 我们可以看到迁移中需要或已应用于开发中的数据库的所有更改。 Than the person responsible for production rolls out code to production after a full backup is made.在进行完整备份后,负责生产的人员将代码推出到生产环境中。 However if you don't use a PHP framework that takes care of this than, awied's suggestion sounds very interesting - I haven't heard of liquidbase before but I will definitely check it out.但是,如果您不使用处理此问题的 PHP 框架,那么 awied 的建议听起来很有趣——我之前没有听说过 Liquidbase,但我一定会检查一下。

There is a tool called iBatis, now called MyBatis that handles versions of databases perfectly.有一个工具叫 iBatis,现在叫 MyBatis,它可以完美地处理数据库的版本。

It takes a little work to have all your changes in script instead of with a graphical tool, but, if you are familiar with coding, it's not a problem.在脚本中而不是使用图形工具进行所有更改需要一些工作,但是,如果您熟悉编码,这不是问题。

When you have multiple databases (like dev-test-prod), you just make 3 environment files and you can update one environment with only one command-line instruction.当你有多个数据库(比如 dev-test-prod)时,你只需要制作 3 个环境文件,你就可以只用一个命令行指令更新一个环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM