2
votes

When using the gcloud shell to import a previously exported firestore database does it trigger any cloud functions if there is a trigger on any of the locations where documents are inserted?

In other words, if I run this command:

gcloud beta firestore import gs://[BUCKET_NAME]/[EXPORT_PREFIX]/

Are the cloud firestore triggers ignored for the inserted documents(onCreate, onUpdate, onDelete and onWrite)?

https://firebase.google.com/docs/firestore/manage-data/export-import

1

1 Answers

3
votes

Short answer: Imports did not trigger any cloud functions to run even when the import resulted in the creation of new documents or triggered updates to existing documents.

Long answer: After some testing, it turns out that importing a previously exported firestore database...

gcloud beta firestore import gs://[BUCKET_NAME]/[EXPORT_PREFIX]/

does not cause the onWrite trigger to be executed. (The onWrite trigger is called for creation, deletion, and updating of documents)

So if you import a document where there is a new value in a document that already exists it will not trigger onWrite (and subsequently not onUpdate)

The import command will only import the documents into the database, it will not delete the old version. So you can import A then import B. The resulting database will contain data from both A and B.

In other words, documents that do not exist in the new import but are present in the live version of the database will NOT be deleted. And the import should not trigger any cloud functions triggers.

(This is just my experience. It's apparently still in beta so I don't know if this is the intended behavior and if it will be true in the future. Hopefully, it will. )