如何捕获已部署应用程序上的数据库和软件版本不匹配的情况?

发布于 2024-07-27 19:28:05 字数 492 浏览 11 评论 0原文

我正在开发一个独立的应用程序,用于访问服务器上的通用数据库。 我的组织中将有几十个人使用它。

我知道我需要更新软件和数据库的设计。 这使得有人可能使用旧软件对数据库执行查询。

我已经有了一个系统,如果用户尝试启动过时版本的应用程序,该系统将会捕获该系统。 然而,这并不能防止有人大部分时间都保持应用程序运行。

我的想法是在数据库中放入一个版本条目(以 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

流年已逝 2024-08-03 19:28:05

某人打开应用程序时间太长,以至于出现新的、不兼容的应用程序部署,并且以结构上兼容但语义上不兼容的方式修改数据库模式(或解释)的用例似乎相当狭窄。

拥有一个包含两个元组的 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.

若相惜即相离 2024-08-03 19:28:05

我认为 tblVersion 的想法可能相当合理,但我会考虑在启动时检查它并立即失败,而不是等待用户尝试对数据库进行写入。

这样做的好处有几个:

  1. 您无需重复检查版本。 您可以在启动时执行一次此操作并保存相当多的查询,特别是如果有很多用户正在使用该系统。
  2. 您不必在数据访问层中进行这些检查。
  3. 无论如何,检查写入可能不是最好的用户体验。 用户将能够加载记录,花几分钟执行一些编辑,然后由于数据库已过时而不得不放弃所有这些。 如果他们无法对数据库执行任何有用的操作,请提前告知他们,而不是在完成编辑后告知。

至少,您应该在应用程序启动时进行检查,并警告用户加载应用程序后将无法保存任何内容。

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:

  1. You avoid the need to repeatedly check the version. You can do this once at startup and save quite a few queries, especially if lots of users are using this system.
  2. You don't have to litter your data access layer with these checks.
  3. Checking on write probably isn't the best user experience anyways. Users would be able to load a record, spend a few minutes performing some edits, and then have to abandon all of those because the database is out-of-date. If they aren't going to be able to do anything useful with the database, let them know ahead of time rather than after they finish their edits.

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.

℡寂寞咖啡 2024-08-03 19:28:05

我认为这可行。

不过,我建议做一些稍微不同的事情。

它有两个部分:

  1. 考虑两种类型的更新——必需的和可选的。 这个想法是,当需要更新时,软件将更有力地进行自我更新。 作为开发人员,您只有在认为需要时才会根据需要标记更新。 我正在开发类似类型的应用程序,并且我发现许多更新实际上与数据库根本没有任何关系......而这些更新类型应该是可选的。
  2. 将代码添加到您的应用程序中,每分钟查询数据库一次以获取当前版本号。 当当前运行版本过时,需要最新更新时,则弹出对话框,要求用户获取更新。 根据您的应用程序,您可能还需要添加允许用户保存其工作的代码。

我认为如果您遵循这种方法,那么您可以在启动期间自动更新应用程序,无论更新是必需的还是可选的。 但当用户实际使用该应用程序时,我只会纠缠用户所需的更新。

I think that could work.

However, I'd suggest something slightly different.

There are two parts to it:

  1. Consider two types of updates -- required and optional. The idea would be that the software would more forcefully update itself when the update is required. And you as the developer would only flag an update as required if you think it needs to be. I work on a similar type of application and many updates that I see don't actually have anything to do with the database at all... and those are the type of updates that should be optional.
  2. Add code to your application that queries your database every minute for the current version number. When the current running version is out-of-date and the latest update is required, then pop up a dialog box that requires the user to get the update. Depending on your application, you may also need to add code that allows the user to save their work.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文