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

时间:2022-10-03 23:54:57

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.

我在开发项目中使用SVN的经验很少,而且我对关系数据库的经验也很少。我知道像表和SQL语句这样的基本概念,但我远非专家。

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.

我想知道的是,是否存在任何通用的版本控制类型系统,如SVN,但它与数据库而不是文件一起工作。我想要与SVN相同的功能,如创建分支,创建标签和合并分支的能力。它不是与文件存储库的版本相关联的修订号,而是与数据库的版本相关联。

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.

他们的任何通用解决方案是否可以添加这种功能而不依赖于实际的数据库模式?我对使用MySQL或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.

我还应该澄清一下,我正在尝试对数据进行版本控制,而不是模式。我希望架构保持不变。所以真的好像我想要一种方法来创建每个版本的数据之间发送数据库的所有INSERT,UPDATE和DELETE请求的日志。这样,可以通过重新发送已保存到所需版本的所有SQL语句来重新创建任何版本。

4 个解决方案

#1


1  

You can script all your DDL, stored procedures and such to regular text files.

您可以将所有DDL,存储过程等脚本编写为常规文本文件。

Then you can simply use SVN for database versioning.

然后,您可以简单地使用SVN进行数据库版本控制。

#2


1  

I've never found a solution that works as well as Subversion, but here's a few things I've done that have helped:

我从来没有找到一个像Subversion一样有效的解决方案,但是我已经完成了一些有帮助的事情:

  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.

    将完整的开发数据库存储在Subversion中。如果有大量数据或经常更改,这对我来说通常不会很好。但在某些项目中可行。

#3


0  

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

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

#4


0  

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

#1


1  

You can script all your DDL, stored procedures and such to regular text files.

您可以将所有DDL,存储过程等脚本编写为常规文本文件。

Then you can simply use SVN for database versioning.

然后,您可以简单地使用SVN进行数据库版本控制。

#2


1  

I've never found a solution that works as well as Subversion, but here's a few things I've done that have helped:

我从来没有找到一个像Subversion一样有效的解决方案,但是我已经完成了一些有帮助的事情:

  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.

    将完整的开发数据库存储在Subversion中。如果有大量数据或经常更改,这对我来说通常不会很好。但在某些项目中可行。

#3


0  

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

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

#4


0  

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