firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 916 forks source link

Allow Firestore emulator to persist data between restarts #7396

Open pmontepagano-dialpad opened 6 days ago

pmontepagano-dialpad commented 6 days ago

We've recently migrated our database from Datastore to "Firestore in Datastore mode". We now want to stop using the Datastore emulator in our tests and local development environments and instead replace it with the Firestore emulator. In other words, we want to replace gcloud beta emulators datastore start with gcloud emulators firestore start --database-mode=datastore-mode.

But unlike Datastore emulator, the Firestore emulator does not persist data. The documentation states:

Because the emulator stores data only in memory, it will not persist data across runs.

This is an inconvenience for local development environments, where engineers expect state to be persisted across restarts. I would like to request a new flag to the Firestore emulator (at least in Datastore mode) to be able to persist state across restarts (and indicate a path where persistence data should be stored).

harshyyy21 commented 5 days ago

Hi @pmontepagano-dialpad, thanks for raising this feature request! I understand the inconvenience of not being able to persist data across emulator restarts. We are aware of this request and do have it in our backlog already. In the meantime, I can point you to import/export for Datastore Mode, that might serve as a workaround for your data persistence problem in the short term: https://cloud.google.com/datastore/docs/emulator#import_entities_into_the_emulator. Please let me know if this is suitable work around for you. If not, I can make some notes as part of the persistence work and push that along.

Note: Persistence is a feature across all of the Firestore Emulator and I believe import/export is how existing Firestore Native customers work around this problem today: https://github.com/firebase/firebase-tools/issues/2269