如何捕获已部署应用程序上的数据库和软件版本不匹配的情况?
我正在开发一个独立的应用程序,用于访问服务器上的通用数据库。 我的组织中将有几十个人使用它。
我知道我需要更新软件和数据库的设计。 这使得有人可能使用旧软件对数据库执行查询。
我已经有了一个系统,如果用户尝试启动过时版本的应用程序,该系统将会捕获该系统。 然而,这并不能防止有人大部分时间都保持应用程序运行。
我的想法是在数据库中放入一个版本条目(以 tblVersion 或类似的形式),并在每次添加、更新或删除数据库中任何表(tblVersion 除外)中的任何记录时检查它,但不仅仅是这样
我就可以捕获(我认为)可能损坏数据库的东西,即使用户拥有过时版本的软件:根据代码中的内容检查数据库中的版本,然后如果存在不匹配,则禁止添加、更新或删除操作。 同时,我不会为数据库读取添加大量检查 tblVersion 的开销。
我的问题:这是声音吗? 有更好的方法吗? 如果是这样,那又怎样?
谢谢!
I'm developing a standalone application that accesses a common database on a server. It will be used by a few dozen people in my organization.
I know that I will need to update the software and the design of the database. This creates the possibility that someone will perform a query on the database using old software.
I already have a system in place that will catch if the user tries to start up an out-of-date version of the application. However, this does not guard against someone who keeps the application up most of the time.
My idea was to put a version entry in the database (in tblVersion or something like that) and check it each time any record in any table in the DB (except tblVersion) is added, updated, or deleted, but not merely read.
This way I could catch things that (I think) could corrupt the DB even if the user has an out-of-date version of the SW: check the version in the DB against what's in the code, and disallow the add, update, or delete operation if there's a mismatch. At the same time, I wouldn't be adding the overhead of a lot of checks to tblVersion for DB reads.
My questions: Is this sound? Is there a better way to go about it? If so, what?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
某人打开应用程序时间太长,以至于出现新的、不兼容的应用程序部署,并且以结构上兼容但语义上不兼容的方式修改数据库模式(或解释)的用例似乎相当狭窄。
拥有一个包含两个元组的 schemaInfo 表,一个包含当前架构版本,另一个包含最后一个兼容版本,将捕获绝大多数情况,同时不会使您的应用程序过于复杂。
检查每次写入将是一个可怕的混乱,如果您真的担心这种情况,请每隔一两个小时设置一个计时器来检查表版本并弹出一个对话框,警告用户获取新版本。
更好的是,一旦完成架构更改,您可以简单地弹回数据库,强制所有现有会话断开连接。
The use case of a person having the app open for so long that a new, incompatible rollout of the app occurs and the database schema (or interpretation) is modified in a structurally compatible, but semantically incompatible way seems pretty narrow.
Having a schemaInfo table with and having two tuples, one with the current schema version and another with the last compatible version is going to catch the vast majority of cases while not overly complicating your application.
Checking on every write would be a horrible mess, if you're really concerned about the scenario, have a timer go off every hour or two that checks the table version and pops up a dialog warning the user to get a new version.
Even better you could simply bounce the DB forcing all existing sessions to disconnect once you've finished a schema change.
我认为 tblVersion 的想法可能相当合理,但我会考虑在启动时检查它并立即失败,而不是等待用户尝试对数据库进行写入。
这样做的好处有几个:
至少,您应该在应用程序启动时进行检查,并警告用户加载应用程序后将无法保存任何内容。
I think the tblVersion idea is probably fairly sound, but I'd consider checking it at start-up instead and immediately failing, rather than waiting for the user to attempt a write on the database.
There's a couple reasons this is beneficial:
At a minimum, you should check at app start-up and warn the user that they won't be able to save anything as soon as they load the application.
我认为这可行。
不过,我建议做一些稍微不同的事情。
它有两个部分:
我认为如果您遵循这种方法,那么您可以在启动期间自动更新应用程序,无论更新是必需的还是可选的。 但当用户实际使用该应用程序时,我只会纠缠用户所需的更新。
I think that could work.
However, I'd suggest something slightly different.
There are two parts to it:
I think if you followed this approach then you could update the application automatically during start-up no matter if the update is required or optional. But then while the user is actually using the application, I'd only pester the user about the required updates.