在Firebase中对对象进行版本控制 [英] Versioning objects in firebase

查看:54
本文介绍了在Firebase中对对象进行版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将firebase用作移动应用程序的数据库.使用特定数据库结构的移动应用程序版本1.但是在版本2中,我进行了主要的架构更改.我找不到任何具体的文档来提及管理数据库升级的最佳实践.因此,我正在考虑以下步骤,这些步骤在纸面上看起来不错.

I am using firebase as a database for a mobile application. Mobile application version 1 using a certain DB structure. But in version 2 I have a major schema changes. I could not find any specific documentation which would mention the best practices for managing DB upgrades. So I am thinking of following steps, which looks good on paper.

  1. 应用程序版本1正在使用 firebase/v1
  2. 进行生产
  3. 将版本1架构 firebase/v1 复制到 firebase/v2
  4. 升级 firebase/v2 模式
  5. firebase/v1
  6. 上禁用写操作
  7. 分发指向 firebase/v2
  8. 的应用程序v2
  1. Application version 1 is in production using firebase/v1
  2. Copy version 1 schema firebase/v1 to firebase/v2
  3. Upgrade firebase/v2 schema
  4. Disable write operations on firebase/v1
  5. Distribute application v2 pointing to firebase/v2

通过这些步骤,具有旧版本应用程序的用户将只能读取数据.因此,除非他们不升级应用程序,否则他们将无法修改任何数据.

With these steps users with older versions app would be able to only read the data. So unless they dont upgrade the app they wont be able to modify any data.

在管理架构更新时,我是否朝着正确的方向前进?还是有更好的方法来做到这一点.

Do I going in the right direction in managing my schema updates? Or is there any better way to do this.

推荐答案

使用云功能数据库功能将数据从db/v1迁移到db/v2.在db/v1中发生更新事件时,您可以并行写入db/v2,因此所有活动用户数据都可以移到db/v2中.

Use cloud function database functions to migrate data from db/v1 to db/v2. On update event in db/v1, you can write to db/v2 in parallel, so all active user data can move into db/v2.

https://firebase.google.com/docs/functions/database-events

尽快迁移数据!

这篇关于在Firebase中对对象进行版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆