如何为最终用户自动升级已部署的数据库 [英] How to automatically upgrade deployed database for end-users

查看:106
本文介绍了如何为最终用户自动升级已部署的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了很多有关如何为开发人员等升级数据库的问题,并且我倾向于使用 migratordotnet 或类似的东西,但是似乎升级需要使用MSBuild或NAnt之类的东西来运行。这些不是我应该期望最终用户安装的东西。



理想情况下,该过程应该是用户安装新版本的应用程序,然后启动它并花费照顾幕后的一切。根据该过程需要花费多长时间,我可能会显示进度条,也可能不会显示进度条,然后完成该操作,使用该应用程序通常会很高兴地不知道是否存在诸如sql,msbuild,关系数据库之类的东西,甚至是任何远程技术方面的东西。 / p>

其他杂项信息:



已安装xcopy的SQLCE。



单个用户数据库很可能不会太大。



随着程序根据用户对请求功能的输入而发展,发布会相当频繁。



尚未完成初始发布,因此
不必担心
当前的任何数据,只需要轻松的
初始和后续
发行的过程(对于最终用户,
最好也适合我!)。



使用LINQ to SQL作为ORM。 (我
是否先升级数据库,然后

运行SQLMetal来重新生成

类?)



这样做TDD(首次)和
想知道如何自动化测试
升级。



Visual C#Express,因此没有VS
插件。



编辑:



我想MSBuild随.NET Framework一起提供,而不仅仅是VS,所以我想这不是问题,我可以只使用migratordotnet并直接封装到msbuild中。如果需要的话,我可能可以重定向控制台输出并进行一些幼稚的字符串解析以获取进度信息,但是如果看起来花了足够的时间来保证显示实际进度而不是仅显示字幕进度条,我将求助于此。

解决方案

以下是一个选项:


  1. 将数据库版本存储在数据库中的某个位置

  2. 在启动时,通过将代码中的常量与数据库版本进行比较,确保数据库是最新的。

  3. 如果不是当前版本,则运行一组脚本来创建/更改表,转换数据等。

如果已经部署并且没有数据库版本,然后只需检查架构以获取您期望的最新数据库版本。



要测试:


  1. 从旧数据库开始

  2. 创建UpdateDatbaseIfNeeded()方法

  3. 如果架构已更新,则测试应通过nd数据库版本已设置

您还可以预加载测试数据库,以测试升级需要处理的各种转换问题脚本。


I've read a fair number of questions on how to upgrade a database for developer and such, and I'm leaning towards using migratordotnet or something similar, however it seems the the upgrades need to be run with something like MSBuild or NAnt. These are not things I should expect an end-user to have installed.

Ideally the process should be the user installs the new version of the app, launches it and it takes care of everything behind the scene. Depending on how long the process takes I may or may not show a progress bar, and then it's done, the use the app normally blissfully unaware that there's such as thing as sql, msbuild, relational database, or anything even remotely technical sounding.

Other misc info:

SQLCE that's xcopy installed.

Single user database that most likely shouldn't be too large.

Releases will be fairly frequent with the program evolving through user input on requested features.

Initial release isn't done yet, so don't need to worry about any current data, just need a painless process for initial and subsequent releases (for the end-user, preferably for me as well!).

Using LINQ to SQL as ORM. (Do I upgrade the database first then
run SQLMetal to regenerate the
classes?)

Doing TDD (for the first time) and wondering how to automate testing upgrades.

Visual C# Express so no VS plugins.

Edit:

I guess MSBuild comes with the .NET Framework and not just VS, so I guess this is a non-issue and I can just use migratordotnet and just shell out to msbuild. If needed I could probably redirect console output and do some naive string parsing to get progress info, but I'll resort to that if it looks like it's taking long enough to warrant displaying actual progress instead of just a marquee progress bar.

解决方案

Here is an option:

  1. Store a db version somewhere in you database
  2. At startup ensure that the database is current by comparing a constant in your code to the db version.
  3. If not current run a set of scripts to create/alter tables, convert data etc.

If you have already deployed and don't have the db version, then just check the schema for something you expect in the latest db version.

To test:

  1. Start with a old database
  2. Create a method to UpdateDatbaseIfNeeded()
  3. The test should pass if the schema gets updated and the db version gets set

You can also preload your test database to test for various conversion issues that need to be handled by your upgrade scripts.

这篇关于如何为最终用户自动升级已部署的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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