How to create multi environment DB's with Firestore

前端 未结 3 1970
醉酒成梦
醉酒成梦 2020-12-15 17:37

I\'ve been looking at how to create multiple Firestore instances in Firebase, I need different Db\'s for prod, staging and development. I read the documentation and seems th

3条回答
  •  一个人的身影
    2020-12-15 17:55

    The safest way is to create a new google cloud project. You can export your current firestore database to your new project if needed.

    Step by step:

    1. Backup your current database by exporting all your documents into a bucket: https://firebase.google.com/docs/firestore/manage-data/export-import

      gcloud beta firestore export gs://[BUCKET_NAME]

    2. Create a new project -> https://cloud.google.com/resource-manager/docs/creating-managing-projects

    3. In the dashboard, select Firestore into your new project and create an empty database
    4. In the dashboard, go to your BACKUP_BUCKET and add your new project service account in the permission tab

    5. Switch project to your new project gcloud config set project 'new-project'

    6. Then export your data gcloud beta firestore import gs://[BUCKET_NAME]/[EXPORT_PREFIX]/ The EXPORT_PREFIX being the name of the folder created in your bucket.

    I use this method to have clearly separated 'preprod' and 'production' environments (the team can access and synchronize with production without having access to the production environment codebase and configuration).

提交回复
热议问题