是否可以将MS VS数据库项目用作数据库版本控制的完整解决方案? [英] Is it possible to use MS VS Database Project as a complete solution for database versioning?

查看:92
本文介绍了是否可以将MS VS数据库项目用作数据库版本控制的完整解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的项目中,我们有几个生产数据库和许多开发人员.每个生产数据库代表一些子项目/本地化版本".我们使用SQL Server 2008.

In our project we have several production databases and many devs. Each production database represents some "sub-project/localization version". We use SQL Server 2008.

因此,我需要使用MS Visual Studio数据库项目开发数据库版本控制策略. 我已经阅读了很多有关数据库版本控制和数据库项目的文章,但是我仍然有很多问题:

So, I need to develop database versioning strategy using MS Visual Studio Database Project. I have read a lot of articles about database versioning and database projects, but I still have a lot of questions:

  1. 开发人员应如何实施 他们对数据库项目的更改? (最佳做法)

  1. How developers should implement theirs changes to db project? (Best practice)

如何生成100%可行的 最新版本"部署脚本 无需人工干预(跳过 一些对象,重写一些更改, 等等)?

How to generate the 100% workable "latest version" deploy script without human intervention (skipping some objects, rewriting some changes, etc)?

如何使用MS管理数据更改 Visual Studio数据库项目?一世 了解部署前/部署后脚本, 但我认为这无法解决 问题. (示例:我需要重新映射 一些表到另一个表中.)

How to manage data changes with MS Visual Studio Database Project? I know about pre-/post-deploy scripts, but I think it cant resolve this problem. (Example: I need to remap some table into another).

理想的解决方案"将是:

The "ideal solution" would be:

  1. 开发人员为数据库[ProductionDB]生成并维护数据库项目.

  1. Developers generates and maintains Database Project for database [ProductionDB].

在新版本中,我将所有必要的内容都部署到[ProductionDB]中 变化.

With new release I deploy Database Project to the [ProductionDB] with all necessary changes.

开发人员更改数据库项目并编写一些数据操作脚本以进行具体更改.

Developers changes Database Project and writes some data manipulation scripts for concrete changes.

在新发行的版本中,我将数据库项目进行了所有必要的更改后部署到了[ProductionDB].

With new release I deploy Database Project to the [ProductionDB] with all necessary changes.

因此,最后一个问题:是否可以出于上述目的使用数据库项目,还是有人使用类似的方案/解决方案?

So, The final question: Is it posible to use Database Project for the purposes described above or somebody uses similar scenario/solution?

PS:我已经阅读了以下讨论:

PS: I have already read following discussions:

  1. 数据库更改版本控制[关闭]
  2. 如何对MS进行版本控制SVN中的SQL数据库?
  3. 寻找数据库版本控制解决方案
  4. 是否有用于数据库结构的版本控制系统变化吗?
  1. Database changes versioning [closed]
  2. How do I version my MS SQL database in SVN?
  3. Looking for solution for database versioning
  4. Is there a version control system for database structure changes?

推荐答案

正是由于您在此处提到的大多数原因,数据库项目才被使用-

Database project is precisely used for most of the reasons that you have mentioned here -

  1. 开发人员只需签出数据库脚本文件,进行更改,然后将其检入.请注意,它们将更改.sql文件,而不是直接存在于任何dev数据库中的对象.因此,如果您需要在数据库表中添加两列,则将修改该表的创建表脚本,而不要为此表编写一个alter脚本.

  1. Developers just checkout the database script files, make the changes, and check them back in. Mind you they will be changing .sql files and not directly the objects present in any dev database. So if you need to add two columns to a database table, you will modify the create table script for this table, and NOT write an alter script for this table.

如果您有目标旧版本DB模式-您可以将带有最新文件的项目部署到该数据库,然后将创建部署脚本(带有必要的alter语句).有一个项目设置,可让您选择在部署"时是否也应针对数据库运行部署脚本.

If you have the target old version DB schema - you can just deploy this project with the latest files to that database and a deployment script will get created (with the necessary alter statements). There is a project setting that allows you to opt whether the deployment script should also be run against the db when you 'deploy'.

部署脚本可以是可交付成果,可以针对产品副本进行单独测试,然后将其作为补丁应用于产品.

The deployment script can be a deliverable that is separately tested against a prod copy and then applied to prod as a patch.

关于数据操作脚本,我不太确定,但是出于您提到的所有其他目的,数据库项目是完美的.

About data manipulation scripts I am not very sure, however for all other purposes that you mentioned, a database project is perfect.

这篇关于是否可以将MS VS数据库项目用作数据库版本控制的完整解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆