数据库部署策略(SQL服务器) [英] Database Deployment Strategies (SQL Server)

查看:130
本文介绍了数据库部署策略(SQL服务器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一种方式来做好日常的部署和保持数据库脚本符合排放。

I am looking for a way to do daily deployments and keep the database scripts in line with releases.

目前,我们已经部署我们的来源相当体面的方式,我们有单位code覆盖,持续集成和回滚过程。

Currently, we have a fairly decent way of deploying our source, we have unit code coverage, continuous integration and rollback procedures.

问题与释放保持数据库脚本行。每个人似乎都尝试剧本出来的测试数据库上,然后在现场运行它们,当ORM映射更新(也就是变化正式上线),那么它拿起新列。

The problem is keeping the database scripts in line with a release. Everyone seems to try the script out on the test database then run them on live, when the ORM mappings are updated (that is, the changes goes live) then it picks up the new column.

第一个问题是,没有脚本的必须是任何地方写的,一般每个人都尝试来把它们放到一个颠覆文件夹,但一些懒惰的人只是在现场运行脚本,大部分没有人知道的时候谁做了什么到数据库。

The first problem is that none of the scripts HAVE to be written anywhere, generally everyone "attempts" to put them into a Subversion folder but some of the lazier people just run the script on live and most of the time no one knows who has done what to the database.

第二个问题是,我们有4测试数据库和他们总是脱节和真正行他们回来的唯一方法是做从活动数据库恢复。

The second issue is that we have 4 test databases and they are ALWAYS out of line and the only way to truly line them back up is to do a restore from the live database.

我是一个大的信徒,像这样的过程需要简单,直接,方便,以用来帮助开发者,不妨碍他们。

I am a big believer that a process like this needs to be simple, straightforward and easy to use in order to help a developer, not hinder them.

我要寻找一些技术/想法,很容易让开发商想记录自己的数据库脚本,使他们能够跑作为释放过程的一部分。 ,开发商会希望遵循一个过程

What I am looking for are techniques/ideas that make it EASY for the developer to want to record their database scripts so they can be ran as part of a release procedure. A process that the developer would want to follow.

任何故事,用例,甚至一个链接会很有帮助。

Any stories, use cases or even a link would helpful.

推荐答案

有关这个非常问题,我选择使用迁移工具:的 Migratordotnet

For this very problem I chose to use a migration tool: Migratordotnet.

随着迁移(在任何工具),你必须用来执行更改并撤销他们一个简单的类。这里有一个例子:

With migrations (in any tool) you have a simple class used to perform your changes and undo them. Here's an example:

[Migration(62)]
public class _62_add_date_created_column : Migration
{
    public void Up()
    {
       //add it nullable
       Database.AddColumn("Customers", new Column("DateCreated", DateTime) );

       //seed it with data
       Database.Execute("update Customers set DateCreated = getdate()");

       //add not-null constraint
       Database.AddNotNullConstraint("Customers", "DateCreated");
    }

    public void Down()
    {
       Database.RemoveColumn("Customers", "DateCreated");
    }
}

此示例显示了如何处理挥发性的更新,如添加新的非空列到已经存在的数据表。这可以很容易地自动的,你可以很容易地去向上和向下版本之间。

This example shows how you can handle volatile updates, like adding a new not-null column to a table that has existing data. This can be automated easily, and you can easily go up and down between versions.

这是一个真正有价值的除了我们的构建,并简化了过程的非常

This has been a really valuable addition to our build, and has streamlined the process immensely.

我张贴在这里。NET的各种迁移框架的比较:<一href=\"http://benscheirman.com/2008/06/net-database-migration-tool-roundup\">http://benscheirman.com/2008/06/net-database-migration-tool-roundup

I posted a comparison of the various migration frameworks in .NET here: http://benscheirman.com/2008/06/net-database-migration-tool-roundup

这篇关于数据库部署策略(SQL服务器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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