Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Versioning objects in firebase

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. 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.

like image 379
kunal Avatar asked Aug 30 '15 07:08

kunal


People also ask

What is orderBy in Firebase?

By default, a query retrieves all documents that satisfy the query in ascending order by document ID. You can specify the sort order for your data using orderBy() , and you can limit the number of documents retrieved using limit() .

Can you store an object in Firebase?

Cloud Storage for Firebase is a powerful, simple, and cost-effective object storage service built for Google scale. The Firebase SDKs for Cloud Storage add Google security to file uploads and downloads for your Firebase apps, regardless of network quality.

How do you filter data in Firebase realtime database?

We can filter data in one of three ways: by child key, by key, or by value. A query starts with one of these parameters, and then must be combined with one or more of the following parameters: startAt , endAt , limitToFirst , limitToLast , or equalTo .

What is the difference between cloud firestore and realtime database?

Cloud Firestore is Firebase's newest database for mobile app development. It builds on the successes of the Realtime Database with a new, more intuitive data model. Cloud Firestore also features richer, faster queries and scales further than the Realtime Database. Realtime Database is Firebase's original database.


1 Answers

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

Migrate data asap!

like image 54
TheWizardJS Avatar answered Oct 07 '22 18:10

TheWizardJS