简体   繁体   English

在Windows和Web App中处理数据库升级的最佳方法是什么?

[英]What's the best way to process database upgrades in Windows and Web App?

I know how to create scripts, but it's knowing how I implement these scripts within a windows app or web application? 我知道如何创建脚本,但是知道如何在Windows应用程序或Web应用程序中实现这些脚本?

Focusing on a web app, I have all upgrade scripts in a folder like: \\install\\upgrade_1.4.99.sql, upgrade_1.4.101.sql etc 专注于Web应用程序,我所有的升级脚本都位于一个文件夹中,例如:\\ install \\ upgrade_1.4.99.sql,upgrade_1.4.101.sql等

C# code checks current code database version with c# version and loops through each sql script in order and runs the script. C#代码使用c#版本检查当前代码数据库版本,并依次遍历每个sql脚本并运行该脚本。

If the user is not an administrator, display appropriate message stating an upgrade is imminent... something similar (logs out user). 如果用户不是管理员,则显示适当的消息,表明即将进行升级...类似的操作(注销用户)。 Administrators (us) are redirected to upgrade webpage and runs the scripts displaying failure or success for each script. 管理员(我们)被重定向到升级网页,并运行显示每个脚本成功或失败的脚本。 A Failure rolls back the SQL Transaction. 失败将回滚SQL事务。

We basically have several instances of one web application and frustrated with the manual upgrades we use to manage. 基本上,我们有一个Web应用程序的多个实例,并且对用于管理的手动升级感到沮丧。

The most prominent issue we had was data upgrades... always missing essential data transfers like static data (configuration settings etc). 我们遇到的最突出的问题是数据升级...总是缺少基本数据传输,例如静态数据(配置设置等)。 So we use RedGate for schema and data upgrade scripting. 因此,我们将RedGate用于架构和数据升级脚本。

So is my method above of upgrading websites the best way to go about this? 那么,上述升级网站的方法是否是实现此目标的最佳方法? Can I assume the same process for windows applications? 我可以为Windows应用程序假设相同的过程吗?

Also I'm certain my method of reading the script file could be improved. 另外,我确定读取脚本文件的方法可以得到改进。 We simply read each line of text in the sql file and wait for a "GO" and save this string into an array before processing them all. 我们只需读取sql文件中的每一行文本,然后等待“ GO”并将此字符串保存到数组中,然后再处理所有字符串。 (I didn't write this code). (我没有写这段代码)。 The process involves one big Begin and Commit Trans... just not sure if this right or not. 该过程涉及一个大的Begin and Commit Trans ...只是不确定是否正确。

Sorry not sure if there are too many questions here. 抱歉,不确定这里是否有太多问题。

You can actually run an entire batch script at once against SQL Server: 实际上,您可以一次对SQL Server运行整个批处理脚本:

http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/43e8bc3a-1132-453b-b950-09427e970f31 http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/43e8bc3a-1132-453b-b950-09427e970f31

As far as what the best way to run updates in any sort of automated fashion? 至于以任何一种自动化方式运行更新的最佳方式是什么? I don't think there is any one great way of doing it. 我认为没有任何一种很棒的方法可以做到这一点。 It's whatever works best for your system. 最适合您的系统的一切。 This goes without saying, but be sure to test scripts in a separate environment as much as possible. 不用说,但是请确保尽可能在单独的环境中测试脚本。

HTH, Brian HTH,布莱恩

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Web服务器上部署可执行进程的最佳方法是什么? - What's the best way to deploy an executable process on a web server? 批处理访问Web应用程序数据库的电子邮件流程的最佳方法 - Best approach for a batch email process that accesses a web app's database 备份Windows Phone App数据库的最佳方法 - Best way to backup Windows Phone App database 在Windows中对程序进行基准测试的最佳方法是什么? - What's the best way to benchmark programs in Windows? 从Windows Universal应用程序将docx / pptx文档转换为PDF的最佳方法是什么? - What's the best way to convert docx/pptx documents to PDF from a Windows Universal App? 读取另一个过程击键的最佳方法是什么? - What's the best way to read another process keystrokes? 监视套接字以获取新数据然后处理该数据的最佳方法是什么? - What's the best way to monitor a socket for new data and then process that data? 从 winforms 应用程序更新远程 web 数据库的最佳方法 - Best way to update remote web database from winforms app 单元测试Windows CE / .NET CF应用程序的最佳方法是什么? - What is the best way to unit test a Windows CE / .NET CF app? .NET Windows窗体应用程序更新自身的最佳方法是什么? - What's the best way for a .NET windows forms application to update itself?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM