数据库中是否有用于版本控制的通用选项?
我在开发项目中使用 SVN 的经验很少,而且我在关系数据库方面的经验也很少。我知道表和 SQL 语句等基本概念,但距离专家还很远。
我想知道是否有像 SVN 这样的通用版本控制类型系统,但它使用数据库而不是文件。我想要与 SVN 相同的功能,例如创建分支、创建标签以及将分支合并在一起的能力。修订号不是与文件存储库的版本相关联,而是与数据库的版本相关联。
他们是否有任何通用解决方案可以添加这种独立于实际数据库模式的功能?我对与 MySQL 或 MS SQL Server 一起使用的解决方案感兴趣。
我还应该澄清,我正在尝试对数据而不是模式进行版本控制。我希望该模式保持不变。所以实际上,我似乎想要一种方法来创建每个数据版本之间发送到数据库的所有 INSERT、UPDATE 和 DELETE 请求的日志。这样,可以通过重新发送已保存到所需版本的所有 SQL 语句来重新创建任何版本。
I have a small amount of experience using SVN on my development projects, and I have just as little experience with relational databases. I know the basic concepts like tables, and SQL statements, but I'm far from being an expert.
What I'd like to know is if there are any generic version control type systems like SVN, but that work with a database rather than files. I would like the same kind of features you get with SVN like the ability to create branches, create tags, and merge branches together. Rather than a revision number being associated to a version of a file repository it would be associated with a version of the database.
Are their any generic solutions available that can add this kind of functionality independent of the actual database schema? I'd be interested in solutions that work with MySQL or MS SQL Server.
I should also clarify that I'm trying to version control the data not the schema. I would expect the schema to remain constant. So really it seems like I want a way to create a log of all the INSERT, UPDATE, and DELETE requests sent the the database between each version of the data. That way any version could be recreated by resending all the SQL statements that have been saved up to the desired version.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以将所有 DDL、存储过程等编写为常规文本文件。
然后您可以简单地使用 SVN 进行数据库版本控制。
You can script all your DDL, stored procedures and such to regular text files.
Then you can simply use SVN for database versioning.
我从未找到过与 Subversion 一样有效的解决方案,但以下是我所做的一些有帮助的事情:
制作将创建架构并填充任何初始数据的脚本。然后为之后的每个更改制作一个更新脚本。这是一个相当手动的过程,但它确实有效。还有一些额外的东西可以帮助您将当前版本号存储在数据库的表中并确保脚本是 幂等。
将完整的开发数据库存储在 Subversion 中。如果数据很多或者经常更改,这对我来说通常效果不太好。但在某些项目中是可行的。
I've never found a solution that works as well as Subversion, but here's a few things I've done that have helped:
Make scripts that will create the schema and populate any initial data. Then make an update script for each change after that. It's a fairly manual process, but it works. There's extra things that help like storing the current version number in a table in the db and making sure that the scripts are idempotent.
Store the full development db in Subversion. This doesn't usually work out too well for me if there is a lot of data or it is frequently changed. But in some projects is could work.
我在版本控制系统中保留并维护创建脚本。
I keep and maintain create scripts in my version control system.
我能想到两件事:
There are two things I can think of: