数据库中是否有用于版本控制的通用选项?

发布于 2024-08-24 06:50:48 字数 424 浏览 2 评论 0原文

我在开发项目中使用 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 技术交流群。

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

发布评论

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

评论(4

花海 2024-08-31 06:50:48

您可以将所有 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.

把人绕傻吧 2024-08-31 06:50:48

我从未找到过与 Subversion 一样有效的解决方案,但以下是我所做的一些有帮助的事情:

  1. 制作将创建架构并填充任何初始数据的脚本。然后为之后的每个更改制作一个更新脚本。这是一个相当手动的过程,但它确实有效。还有一些额外的东西可以帮助您将当前版本号存储在数据库的表中并确保脚本是 幂等

  2. 将完整的开发数据库存储在 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:

  1. 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.

  2. 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.

幽梦紫曦~ 2024-08-31 06:50:48

我在版本控制系统中保留并维护创建脚本。

I keep and maintain create scripts in my version control system.

晚风撩人 2024-08-31 06:50:48

我能想到两件事:

  • http://www.liquibase.org/ - 提供了一种方法一般管理数据库更改。创建提交到源代码管理的文件,它有助于管理不同开发数据库之间的更改等。
  • http://www.viget.com/extend/backup-your-database-in-git/ - 这描述了将数据库备份到源代码管理的策略,但策略相同只能在模式上使用。在此方案中,数据库将位于与主代码不同的区域中。 (这也可以与其他源代码控制系统一起使用。)

There are two things I can think of:

  • http://www.liquibase.org/ - provides a way of generally managing database changes. Creates files that get committed into source control, and it helps manage changes across different development databases, etc.
  • http://www.viget.com/extend/backup-your-database-in-git/ - this describes a strategy for backing up a database into source control, but the same strategy can be used just on the schema. In this scheme, the database would be in a separate area from your main code. (This can be used with other source control systems too.)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文