在ASP.NET版本分支/回滚之间数据库更改处理 [英] Dealing with Database changes between version branches/rollbacks in ASP.NET

查看:162
本文介绍了在ASP.NET版本分支/回滚之间数据库更改处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET项目。当然,通过不同的版本和开发分支,数据库架构更改。

I have an ASP.NET project. Naturally, through different releases and development branches, the db schema changes.

有什么办法来处理干净,友好地架构更改,这样我可以开发分支之间轻松切换?

What are some ways to cleanly handle the schema changes in a friendly way so that I can easily switch between development branches?

我使用SQL Server 2005,但一般的技术可能会工作。

I use SQL Server 2005, but general techniques probably work.

推荐答案

一个很好的方法来跟踪整个开发项目的多个分支架构更改会遵循的数据库重构过程。除了其他优点,这种工艺结合使用增量和迁移脚本的应用模式更改每个环境(或分支机构在您的案件)。设置可以是这个样子:

One good way to keep track of schema changes across multiple branches of a development project would be to follow a database refactoring process. Among other benefits, this sort of process incorporates the use of delta and migration scripts to apply schema changes to each environment (or branch in your case). The setup could look something like this:

main
  src <-- ASP.NET project source
  db <-- Database create scripts
  delta <-- Database change scripts (SQL delta files)

branch
  src
  db <-- usually has the same contents as the copy in main branch
  delta <-- only the changes necessary for this branch

每当你需要更改数据库架构为您创建一个用于应用变化的SQL脚本三角洲特定分支。为了更方便,我建议每个命名脚本文件,包括创建日期和时间,让他们按顺序排列。例子是:

Every time you need to change the database schema for a particular branch you create a SQL delta script that is used to apply the change. To make it easier I would suggest naming each script file to include create date and time to keep them in sequence. Example would be:

201102231435_addcolumn.sql
201102231447_addconstraint.sql
201103010845_anotherchange.sql

增量文件添加到源代码控制在模式更改需要进行分支。您应该结束了与含究竟是什么需要改变相应的数据库中的每个分支。一些细节可能需要调整您的具体情况取决于事情喜欢你的分支计划以及是否您的数据库中的释放过程preserved(而不是重新创建)。

Add the delta files to source control in the branch where the schema change needs to be made. You should end up with each branch containing exactly what is necessary to change the corresponding database. Some details might need to be tweaked for your situation depending on things like your branching scheme and whether or not your database is preserved during your release process (as opposed to re-created).

最后,试图使这些概念简单,我会推荐一种工具来帮助管理流程。我的建议是看看 DBDeploy /的 DBDeploy.NET 。我一直快乐地使用多年对我的所有项目。

Finally, to try and make these concepts simple, I would recommend a tool to help manage the process. My suggestion is to take a look at DBDeploy / DBDeploy.NET. I've been happily using it for years on all my projects.

这篇关于在ASP.NET版本分支/回滚之间数据库更改处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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