数据库版本控制 - 分支切换如何工作?
对于那些在开发团队中进行开发的人来说,这是一个问题,其中所有人都有单独的数据库。您使用源代码控制和其他工具对数据库进行版本控制,这些工具将自动将开发数据库更新为最新版本的数据库(架构、数据、SP、函数等)。
好的,太好了!但是等等!如果您正在软件 4.0 版本上进行开发,但现在需要将分支切换到 3.2 分支来修复错误,该怎么办?现在,模式可能(几乎肯定是)非常不同......
我想如果您付出额外的努力来编写回滚脚本以及更改脚本,这可能会起作用。但这看起来工作量很大——真的值得吗?
This is a question for those of you developing on a team of devs where all of you have separate databases. You're versioning your database using source control and other tools which will automatically bring dev databases up to date to the latest version of the database (schema, data, SP's, functions, etc.).
OK Great! But wait! What if you are developing on version 4.0 of your software, but now you need to switch branches to the 3.2 branch to fix a bug? The schema could be (almost assuredly is) very different by now...
I suppose if you went through the extra effort to write rollback scripts along with your change scripts, this could work. But that seems like a lot of work - is it really worth it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个新的 3.2 分支数据库并在处理 3.2 分支代码时使用该数据库会更容易。在我看来,要求每个开发人员都只有一个数据库可以使用是不合理的。
Much easier would be to create a new 3.2-branch database and work with that while working on the 3.2-branch code. It doesn't seem reasonable to me to require that each developer has exactly one database to work with.
我假设您正在将数据库版本化为二进制文件?如果您的所有数据库资产都是构造性代码的形式(例如 SQL 脚本和/或文本数据转储),那么解决方案将很简单,正如 Mark 所建议的:将这些资产存储为开发分支的一部分。要在版本 3.2 上工作,请切换分支,重新运行创建脚本和 presto,3.2 数据库。合并将与常规代码一样简单(或者同样痛苦,具体取决于您选择的版本控制系统)。
以下是在此模式下工作的一些建议:
I'm going on a limb and assume that you are versioning the database as a binary? If all your database assets were in the form of constructive code (eg SQL scripts and/or text data dumps), the solution would be simple, as suggested by Mark: store these assets as part of the development branch. To work on version 3.2, switch the branch, re-run the create scripts and presto, 3.2 database. Merging would be just as easy as with regular code (or just as painful, depending on your version control system of choice).
Here are some suggestions to work in this mode: