user3240644
user3240644

Reputation: 2281

Firebase Database Migration

Coming from a SQL background, I'm wondering how does one go about doing database migration in 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}. How do I update firebase such that all dateFrom: xxxx and timeFrom: yyyy are removed and replaced with dateTimeFrom: xxxxyyyy? Thanks.

Upvotes: 23

Views: 9616

Answers (4)

1. Ensure You Have the Firebase Admin SDK for your_project Go to the Firebase Console. Select your your_project project. Navigate to Project settings > Service accounts. Click "Generate new private key" and save the JSON file securely. This file contains sensitive information that allows full access to your Firebase services.

npm install -g node-firestore-import-export

firestore-export --accountCredentials D:\path\filename.json --backupFile D:\path\backup.json --nodePath collection_name

firestore-import --accountCredentials D:\path\project-prod-firebase-adminsdk.json --backupFile D:\path\backup.json

Upvotes: 0

bias
bias

Reputation: 1474

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.

Firebase DB migration feature

You can also submit a DB migration feature request to increase the likelihood that they create the feature.

Upvotes: 1

Pablo Ezequiel Leone
Pablo Ezequiel Leone

Reputation: 1387

I think you are looking for this: 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.

Upvotes: 8

Seb
Seb

Reputation: 506

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)

Upvotes: 5

Related Questions