当应用程序是全新的时,如何向下兼容客户旧的本地数据库?

发布于 2024-09-19 01:52:12 字数 221 浏览 7 评论 0原文

我希望我的用户在 10 年后仍然可以读取我的 sqlite 数据库,因为其中可能有他们想要浏览的数据。

数据库文件已有 10 年历史了。与此同时,我升级了我的数据库结构(附加字段是最好的例子),我的应用程序的最新版本使用了这些新字段。

现在,用户想要使用全新的应用程序版本加载 10 年前的数据库。但这是行不通的,因为在旧的数据库文件中缺少一些字段。

遇到这样的情况你会如何处理?

I want that my users can read my sqlite database still in 10 years, because there could be data in it they want to browse.

Well the database file is 10 years old. In the meantime I have upgraded my database structure (additional fields is best example) and my latest version of the application makes use of that new fields.

Now the user wants to load the 10 year old database with the brandnew application version. But that won`t work, because in the old database file there are some fields missing.

How would you deal with such a scenario?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

人│生佛魔见 2024-09-26 01:52:12

处理此问题的最简单方法是保留您的新应用程序。让它只适用于新格式。从长远来看,这会更容易,因为您的程序不必考虑使用一堆不同的数据结构。

创建一个程序,将旧数据库文件“升级”(创建一个新文件并传输数据等,或者以您想要的方式处理它)以类似于新文件。

The easiest way to handle this is to leave your new application alone. Have it only work with the new format. In the long run this will be easier, because your program won't have to account for working with a bunch of different data structures.

Create a program which "upgrades" (creates a new file and transfers the data etc. or however you want to handle it) the old database file to resemble the new one.

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