Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate dev and prod Firebase environment

I am considering using Firebase as MBaaS, however I couldn't find any reliable solution to the following problem:

I would like to set up two separate Firebase environments, one for development and one for production, but I don't want to do a manual copy of features (eg. remote configuration setup, notification rules, etc.) between the development and production environment.

Is there any tool or method I can rely on? Setting up remote configuration or notification rules from scratch can be a daunting task and too risky.

Any suggestions? Is there a better approach than having two separate environments?

Before you post another answer to the question which explains how to set up separate Firebase accounts: it is not the question, read it again. The question is: how to TRANSFER changes between separate dev and prod accounts or any better solution than manually copy between them.

like image 721
racs Avatar asked May 26 '16 02:05

racs


People also ask

Can two apps use same Firebase database?

Yes, You can use the same firebase database in more than one android application as below: In the Project Overview section of Firebase Console add an android application. For adding this application first you need to give that package name.

Can I use two Firebase for my website?

However, when you want to access multiple projects from a single application, you'll need a distinct Firebase application object to reference each one individually. It's up to you to initialize these other instances.

Can a Firebase project have multiple apps?

You're limited to one database per project. You'll need multiple projects to get multiple db instances. You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.


2 Answers

If you are using firebase-tools there is a command firebase use which lets you set up which project you are using for firebase deploy

firebase use --add will bring up a list of your projects, select one and it will ask you for an alias. From there you can firebase use alias and firebase deploy will push to that project.

In my personal use, I have my-app and my-app-dev as projects in the Firebase console.

like image 110
Lunchbox Avatar answered Sep 21 '22 17:09

Lunchbox


As everyone has pointed out - you need more than one project/database.

But to answer your question regarding the need to be able to copy settings/data etc from development to production. I had the exact same need. A few months in development and testing, I didn't want to manually copy the data.

My result was to backup the data to a storage bucket, and then restore it from there into the other database. It's a pretty crude way to do it - and I did a whole database backup/restore - but you might be able to look in that direction for a more controlled way. I haven't used it - it's very new - but this might be a solution: NPM Module firestore-export-import

Edit: Firestore backup/export/import info here Cloud Firestore Exporting and Importing Data

If you're using Firebase RTDB, and not Firestore - this documentation might help: Firebase Automated Backups

You will need to set the permissions correctly to allow your production database access to the same storage bucket as your development. Good luck.

like image 33
stevecowling Avatar answered Sep 20 '22 17:09

stevecowling