简体   繁体   English

Firebase 数据库迁移

[英]Firebase Database Migration

Coming from a SQL background, I'm wondering how does one go about doing database migration in firebase?来自 SQL 背景,我想知道一个 go 如何在 firebase 中进行数据库迁移?

Assume I have the following data in firebase {dateFrom: 2015-11-11, timeFrom: 09:00}.... and now the front-end client will store and expects data in the form {dateTimeFrom: 2015-011-11T09:00:00-07:00} .假设我在 firebase {dateFrom: 2015-11-11, timeFrom: 09:00}....中有以下数据,现在前端客户端将以{dateTimeFrom: 2015-011-11T09:00:00-07:00}的形式存储并期望数据{dateTimeFrom: 2015-011-11T09:00:00-07:00} How do I update firebase such that all dateFrom: xxxx and timeFrom: yyyy are removed and replaced with dateTimeFrom: xxxxyyyy ?如何更新 firebase 以便删除所有dateFrom: xxxxtimeFrom: yyyy并替换为dateTimeFrom: xxxxyyyy Thanks.谢谢。

I think you are looking for this: https://github.com/kevlened/fireway我想你正在寻找这个: https://github.com/kevlened/fireway

I think is a bad idea to pollute a project with conditionals to update data on the fly.我认为用条件来污染项目以动态更新数据是一个坏主意。

It is a shame firestore doesn't implement a process for this as it is very common and required to keep the app and db in sync.遗憾的是,firestore 没有为此实现一个过程,因为它很常见并且需要保持应用程序和数据库同步。

You have to create your own script that reads, transform and write it back. 您必须创建自己的脚本来读取,转换和写回。 You may eider read one node at the time or read the whole DB if it is not big. 您可以在此时读取一个节点,或者读取整个数据库(如果它不大)。 You may decide to leave the logic to your client when it access to it (if it ever does) 您可以决定在访问它时将逻辑留给您的客户端(如果有的话)

FWIW, since I'm using Swift and there isn't a solution like Fireway (that I know of), I've submitted a feature request to the Firebase team that they've accepted as a potential feature. FWIW,因为我使用的是 Swift 并且没有像 Fireway 这样的解决方案(据我所知),我已经向 Firebase 团队提交了一个功能请求,他们已经接受了这个潜在功能。

Firebase 数据库迁移功能

You can also submit a DB migration feature request to increase the likelihood that they create the feature.您还可以提交数据库迁移功能请求,以增加他们创建该功能的可能性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM