我想让我的数据库处于版本控制之下。
我总是希望在那里至少有一些数据(如alumb提到的:用户类型和管理员)。我还经常需要大量生成的测试数据来进行性能度量。
如何对数据库应用版本控制?
我想让我的数据库处于版本控制之下。
我总是希望在那里至少有一些数据(如alumb提到的:用户类型和管理员)。我还经常需要大量生成的测试数据来进行性能度量。
如何对数据库应用版本控制?
当前回答
首先,你必须选择适合你的版本控制系统:
Centralized Version Control system - a standard system where users check out/check in before/after they work on files, and the files are being kept in a single central server Distributed Version Control system - a system where the repository is being cloned, and each clone is actually the full backup of the repository, so if any server crashes, then any cloned repository can be used to restore it After choosing the right system for your needs, you'll need to setup the repository which is the core of every version control system All this is explained in the following article: http://solutioncenter.apexsql.com/sql-server-source-control-part-i-understanding-source-control-basics/
在建立了存储库之后,如果有一个中央版本控制系统,那么就有一个工作文件夹,您可以阅读本文。它展示了如何在开发环境中使用以下命令来设置源代码控制:
通过MSSCCI提供的SQL Server Management Studio, Visual Studio和SQL Server数据工具 一个第三方工具ApexSQL源代码控制
其他回答
查看DBGhost http://www.innovartis.co.uk/。我已经在一个自动化的方式使用了2年,它工作得很好。它允许我们的DB构建非常像Java或C构建,除了数据库。你们能明白我的心情
在Red Gate,我们提供了一个工具,SQL Source Control,它使用SQL Compare技术将数据库与TFS或SVN存储库链接起来。该工具集成到SSMS中,让您像往常一样工作,只是现在允许提交对象。
对于基于迁移的方法(更适合于自动化部署),我们提供了SQL Change Automation(以前称为ReadyRoll),它作为Visual Studio项目创建和管理一组增量脚本。
在SQL源代码控制中,可以指定静态数据表。它们作为INSERT语句存储在源代码控制中。
如果您正在讨论测试数据,我们建议您要么使用工具生成测试数据,要么通过您定义的部署后脚本生成测试数据,要么简单地将生产备份恢复到开发环境。
首先,你必须选择适合你的版本控制系统:
Centralized Version Control system - a standard system where users check out/check in before/after they work on files, and the files are being kept in a single central server Distributed Version Control system - a system where the repository is being cloned, and each clone is actually the full backup of the repository, so if any server crashes, then any cloned repository can be used to restore it After choosing the right system for your needs, you'll need to setup the repository which is the core of every version control system All this is explained in the following article: http://solutioncenter.apexsql.com/sql-server-source-control-part-i-understanding-source-control-basics/
在建立了存储库之后,如果有一个中央版本控制系统,那么就有一个工作文件夹,您可以阅读本文。它展示了如何在开发环境中使用以下命令来设置源代码控制:
通过MSSCCI提供的SQL Server Management Studio, Visual Studio和SQL Server数据工具 一个第三方工具ApexSQL源代码控制
我写了这个应用程序一段时间前,http://sqlschemasourcectrl.codeplex.com/,它会扫描你的MSFT SQL db的经常你想,并自动转储你的对象(表,视图,procs,函数,SQL设置)到SVN。效果非常好。我把它和unduddle一起使用(它可以让我在签到时收到提醒)
每个推荐RedGate工具的人都要加1分,还有额外的建议和警告。
SqlCompare also has a decently documented API: so you can, for instance, write a console app which syncs your source controlled scripts folder with a CI integration testing database on checkin, so that when someone checks in a change to the schema from their scripts folder it's automatically deployed along with the matching application code change. This helps close the gap with developers who are forgetful about propagating changes in their local db up to a shared development DB (about half of us, I think :) ).
A caveat is that with a scripted solution or otherwise, the RedGate tools are sufficiently smooth that it's easy to forget about SQL realities underlying the abstraction. If you rename all the columns in a table, SqlCompare has no way to map the old columns to the new columns and will drop all the data in the table. It will generate warnings but I've seen people click past that. There's a general point here worth making, I think, that you can only automate DB versioning and upgrade so far - the abstractions are very leaky.