在安装程序中从 .NET 代码升级 sqlite 数据库的标准做法是什么
我有一个使用 sqlite 数据库的 .NET 应用程序。在最新版本中,我们需要升级架构。我想知道在安装程序中从 .NET 代码升级 sqlite 数据库的标准做法是什么?我们将 Wix 与在 .NET 程序集中实现的自定义操作一起使用。
谢谢,
I have a .NET application that uses a sqlite database. In the latest release we need to upgrade the schema. I am wondering what is the standard practice to upgrade a sqlite database from .NET code in an installer? We use Wix with custom actions implemented in a .NET assembly.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WiX 和 InstallShield 等工具仅对 SQL(WiX、InstallShield)、Oracle(InstallShield)和 MySQL(InstallShield - 需要 MySQL Connect)提供本机支持。据我所知,MSI 中没有任何原生的东西,也没有其他现成的安装程序解决方案。
您当然可以推出自己的(希望是数据驱动的)自定义操作来处理此问题,但如果是我,我会考虑在应用程序层中实现数据库服务。这样,您的应用程序就具有更高的容错性和自助服务性,无需安装程序的帮助。
例如,如果客户要升级您的安装程序,然后恢复数据库的旧版本,您的应用程序将能够将其自行升级到新架构。
Tools such as WiX and InstallShield only have native support for SQL ( WiX, InstallShield ), Oracle ( InstallShield ) and MySQL ( InstallShield - Requires MySQL Connect ). There is nothing native in MSI and no other off the shelf solutions for installers that I'm aware of.
You can certainly roll your own ( hopefully data driven ) custom actions for dealing with this but if it was me I'd consider implementing your database servicing in your application layer. This way your application is more fault tolerant and self servicing without needing the help of an installer.
For example if a customer was to upgrade your installer then restore an older version of your database, your application would be able to self upgrade it to the new schema.
一种方法是创建一个 diff sql 脚本 - 通过添加、更新或删除可能更改的部分来更新现有架构 - 并针对过时的数据库执行它。
这应该足够了,因为它将用新的模式更改原始模式。
顺便问一下,数据怎么样?如果数据库架构已更改,也许您需要迁移以前的数据库日期。
如果我没记错的话,您想从代码中执行此操作,这允许您创建过时数据库的备份。创建此类备份后,您应该执行架构更新后操作以迁移数据,最后您可以(或不)删除备份。
An approach would be creating a diff sql script - one updating existing schema by adding, updating or removing parts that may be changed - and execute it against outdated database.
That should be enough, since it'll change original schema with the new one.
By the way, what about the data? If database schema has changed, maybe you'll need to migrate previous database date.
If I'm not wrong, you want to do that from code, and this allows you to create a backup of the outdated database. After creating such backup, you should perform a post-schema-update action in order to migrate data, and finally you can (or not) remove the backup.