版本控制我的SQL server存储过程的最佳方式是什么?

时间:2022-05-02 23:07:45

What is the best way to version control my database objects? I'm using Visual studio 2005/2008 and SQL server 2005. I would prefer a solution which can be used with SVN.

版本控制数据库对象的最佳方式是什么?我使用的是Visual studio 2005/2008和SQL server 2005。我想要一个可以和SVN一起使用的解决方案。

10 个解决方案

#1


33  

Same as your other code, add a "Database project" to your application solution and keep the sql files used to build the database objects in there. Use the same version control for those code files as you do for the application.

与其他代码一样,在应用程序解决方案中添加“数据库项目”,并在其中保存用于构建数据库对象的sql文件。对这些代码文件使用与应用程序相同的版本控制。

#2


15  

Look at the tools offered by RedGate. They specifically deal with backup / restore / comparison cases for SQL Server objects including SP's. Alternately I am not sure but I think that Visual Studio allows you to check sp's into a repository. Havent tried that myself. But I can recommend RedGate tools. They have saved me a ton of trouble

看看RedGate提供的工具。它们专门处理SQL服务器对象(包括SP)的备份/恢复/比较情况。另外,我也不确定,但是我认为Visual Studio允许您将sp检入到存储库中。没试过自己。但是我可以推荐RedGate工具。他们给我省去了许多麻烦

#3


5  

I use SVN for all of my table/sproc/function source control.

我所有的表/sproc/函数源代码控制都使用SVN。

I couldn't find anything that met my needs so I ended up writing a utility to allow me to dump the code out into a nice directory structure to use with SVN.

我找不到任何满足我需要的东西,所以我最后编写了一个实用程序,允许我将代码转储到一个很好的目录结构中,以便与SVN一起使用。

For those interested, the source is now available at svn://finsel.com/public/VS2005/GenerateSVNFilesForSQL2005.

对于那些感兴趣的人,该源代码现在可以在svn:/ finsel.com/public/vs2005 / generatesvnfilesforsql2005上获得。

#4


3  

We use Subversion and all we do is save the sql code in the directory for our subversion project and then commit the code to the repository when we are ready and update from the repository before we start working on something already in there.

我们使用Subversion,我们所做的就是将sql代码保存在Subversion项目的目录中,然后在准备就绪时将代码提交给存储库,并在开始处理已有内容之前从存储库中进行更新。

The real trick is to convince developers to do that. Our dbas do that by deleting any stored proc (or other database object) that isn't in Subversion periodically. Lose stuff once and pretty much no one does it again.

真正的诀窍是说服开发人员这样做。我们的dba通过定期删除Subversion中未存储的任何proc(或其他数据库对象)来实现这一点。丢东西一次,几乎没有人再做一次。

#5


1  

I don't know of a pre-packaged solution, sorry...

我不知道预包装的解决方案,对不起……

... but couldn't you just a little script that connected to the database and saved all the stored procedures to disk as text files? Then the script would add all the text files to the SVN repository by making a system call to 'svn add'.

…但是,难道您就不能使用一个连接到数据库并将所有存储过程保存为文本文件的小脚本吗?然后脚本将通过对“SVN add”进行系统调用,将所有文本文件添加到SVN存储库。

Then you'd probably want another script to connect to the DB, drop all stored procedures and load all the repository stored procedures from disk. This script would need to be run each time you ran "svn up" and had new/changed stored procedures.

然后,您可能希望另一个脚本连接到DB,删除所有存储过程,并从磁盘加载所有存储库存储过程。每次运行“svn up”并有新的/更改的存储过程时,都需要运行此脚本。

I'm not sure if this can be accomplished with MS SQL, but I'm fairly confident that MySQL would accommodate this. If writing SVN extensions to do this is too complicated, Capistrano supports checkin/checkout scripts, IIRC.

我不确定用MS SQL是否可以实现这一点,但我很有信心MySQL能够适应这一点。如果编写SVN扩展来完成这一任务太复杂了,Capistrano支持checkin/checkout脚本,IIRC。

#6


1  

Best way - one which works for you.

最好的方法——对你有效的方法。

Easiest way - one that doesn't currently exist.

最简单的方法——目前还不存在。

We use a semi-manual method (scripts under source control, small subset of people able to deploy stored procedures to the production server, changes to the schema should be reflected in changes to the underlying checked in files).

我们使用一种半手动方法(源代码控制下的脚本,能够将存储过程部署到生产服务器的一小部分人,模式的更改应该反映在文件中检查的底层更改中)。

What we should do is implement some sort of source control vs plaintext schema dump diff ... but it generally 'works for us' although it's a really faff most of the time.

我们应该做的是实现某种源代码控制,而不是明文模式转储。但它通常“适用于我们”,尽管它在大多数情况下都是一场骗局。

#7


1  

I agree that if possible, you should use database projects to version your db along with your application source.

我同意,如果可能的话,您应该使用数据库项目对db和应用程序源代码进行版本化。

However, if you are in an enterprise scenario, you should also consider using a tool to track changes on the server, and version those changes. Just because the database project exists doesn't mean some admin or developer can't change those sprocs on the server.

但是,如果您在企业场景中,您还应该考虑使用工具跟踪服务器上的更改,并对这些更改进行版本化。仅仅因为数据库项目存在,并不意味着某些管理员或开发人员不能更改服务器上的sproc。

#8


0  

We do dumps to plaintext and keep them in our VCS.

我们将转储文件转换为明文,并将它们保存在我们的VCS中。

You'd be able to script a backup-and-commit to do something similar.

您可以编写一个备份提交来执行类似的操作。

#9


0  

I'm using scriptdb.exe from http://scriptdb.codeplex.com/

我用scriptdb。exe从http://scriptdb.codeplex.com/

And it might be usefull to use the rails way: http://code.google.com/p/migratordotnet/wiki/GettingStarted

使用rails的方式可能是有用的:http://code.google.com/p/migratordotnet/wiki/GettingStarted

#10


0  

Use versaplex for dumping your schema: http://code.google.com/p/versaplex/

使用versaplex来转储您的模式:http://code.google.com/p/versaplex/

Versaplex comes with Schemamatic, which reads database schema (tables, SPs, etc) and also data (data is dumped as CSV). I use it, with SVN and git, and it's awesome :) If you need help let me know, it's worth a try! http://github.com/eduardok/versaplex

Versaplex附带了Schemamatic,它读取数据库模式(表、SPs等)和数据(数据被作为CSV转储)。我使用它,与SVN和git,它是可怕的:)如果你需要帮助让我知道,值得一试!http://github.com/eduardok/versaplex

#1


33  

Same as your other code, add a "Database project" to your application solution and keep the sql files used to build the database objects in there. Use the same version control for those code files as you do for the application.

与其他代码一样,在应用程序解决方案中添加“数据库项目”,并在其中保存用于构建数据库对象的sql文件。对这些代码文件使用与应用程序相同的版本控制。

#2


15  

Look at the tools offered by RedGate. They specifically deal with backup / restore / comparison cases for SQL Server objects including SP's. Alternately I am not sure but I think that Visual Studio allows you to check sp's into a repository. Havent tried that myself. But I can recommend RedGate tools. They have saved me a ton of trouble

看看RedGate提供的工具。它们专门处理SQL服务器对象(包括SP)的备份/恢复/比较情况。另外,我也不确定,但是我认为Visual Studio允许您将sp检入到存储库中。没试过自己。但是我可以推荐RedGate工具。他们给我省去了许多麻烦

#3


5  

I use SVN for all of my table/sproc/function source control.

我所有的表/sproc/函数源代码控制都使用SVN。

I couldn't find anything that met my needs so I ended up writing a utility to allow me to dump the code out into a nice directory structure to use with SVN.

我找不到任何满足我需要的东西,所以我最后编写了一个实用程序,允许我将代码转储到一个很好的目录结构中,以便与SVN一起使用。

For those interested, the source is now available at svn://finsel.com/public/VS2005/GenerateSVNFilesForSQL2005.

对于那些感兴趣的人,该源代码现在可以在svn:/ finsel.com/public/vs2005 / generatesvnfilesforsql2005上获得。

#4


3  

We use Subversion and all we do is save the sql code in the directory for our subversion project and then commit the code to the repository when we are ready and update from the repository before we start working on something already in there.

我们使用Subversion,我们所做的就是将sql代码保存在Subversion项目的目录中,然后在准备就绪时将代码提交给存储库,并在开始处理已有内容之前从存储库中进行更新。

The real trick is to convince developers to do that. Our dbas do that by deleting any stored proc (or other database object) that isn't in Subversion periodically. Lose stuff once and pretty much no one does it again.

真正的诀窍是说服开发人员这样做。我们的dba通过定期删除Subversion中未存储的任何proc(或其他数据库对象)来实现这一点。丢东西一次,几乎没有人再做一次。

#5


1  

I don't know of a pre-packaged solution, sorry...

我不知道预包装的解决方案,对不起……

... but couldn't you just a little script that connected to the database and saved all the stored procedures to disk as text files? Then the script would add all the text files to the SVN repository by making a system call to 'svn add'.

…但是,难道您就不能使用一个连接到数据库并将所有存储过程保存为文本文件的小脚本吗?然后脚本将通过对“SVN add”进行系统调用,将所有文本文件添加到SVN存储库。

Then you'd probably want another script to connect to the DB, drop all stored procedures and load all the repository stored procedures from disk. This script would need to be run each time you ran "svn up" and had new/changed stored procedures.

然后,您可能希望另一个脚本连接到DB,删除所有存储过程,并从磁盘加载所有存储库存储过程。每次运行“svn up”并有新的/更改的存储过程时,都需要运行此脚本。

I'm not sure if this can be accomplished with MS SQL, but I'm fairly confident that MySQL would accommodate this. If writing SVN extensions to do this is too complicated, Capistrano supports checkin/checkout scripts, IIRC.

我不确定用MS SQL是否可以实现这一点,但我很有信心MySQL能够适应这一点。如果编写SVN扩展来完成这一任务太复杂了,Capistrano支持checkin/checkout脚本,IIRC。

#6


1  

Best way - one which works for you.

最好的方法——对你有效的方法。

Easiest way - one that doesn't currently exist.

最简单的方法——目前还不存在。

We use a semi-manual method (scripts under source control, small subset of people able to deploy stored procedures to the production server, changes to the schema should be reflected in changes to the underlying checked in files).

我们使用一种半手动方法(源代码控制下的脚本,能够将存储过程部署到生产服务器的一小部分人,模式的更改应该反映在文件中检查的底层更改中)。

What we should do is implement some sort of source control vs plaintext schema dump diff ... but it generally 'works for us' although it's a really faff most of the time.

我们应该做的是实现某种源代码控制,而不是明文模式转储。但它通常“适用于我们”,尽管它在大多数情况下都是一场骗局。

#7


1  

I agree that if possible, you should use database projects to version your db along with your application source.

我同意,如果可能的话,您应该使用数据库项目对db和应用程序源代码进行版本化。

However, if you are in an enterprise scenario, you should also consider using a tool to track changes on the server, and version those changes. Just because the database project exists doesn't mean some admin or developer can't change those sprocs on the server.

但是,如果您在企业场景中,您还应该考虑使用工具跟踪服务器上的更改,并对这些更改进行版本化。仅仅因为数据库项目存在,并不意味着某些管理员或开发人员不能更改服务器上的sproc。

#8


0  

We do dumps to plaintext and keep them in our VCS.

我们将转储文件转换为明文,并将它们保存在我们的VCS中。

You'd be able to script a backup-and-commit to do something similar.

您可以编写一个备份提交来执行类似的操作。

#9


0  

I'm using scriptdb.exe from http://scriptdb.codeplex.com/

我用scriptdb。exe从http://scriptdb.codeplex.com/

And it might be usefull to use the rails way: http://code.google.com/p/migratordotnet/wiki/GettingStarted

使用rails的方式可能是有用的:http://code.google.com/p/migratordotnet/wiki/GettingStarted

#10


0  

Use versaplex for dumping your schema: http://code.google.com/p/versaplex/

使用versaplex来转储您的模式:http://code.google.com/p/versaplex/

Versaplex comes with Schemamatic, which reads database schema (tables, SPs, etc) and also data (data is dumped as CSV). I use it, with SVN and git, and it's awesome :) If you need help let me know, it's worth a try! http://github.com/eduardok/versaplex

Versaplex附带了Schemamatic,它读取数据库模式(表、SPs等)和数据(数据被作为CSV转储)。我使用它,与SVN和git,它是可怕的:)如果你需要帮助让我知道,值得一试!http://github.com/eduardok/versaplex