Repository navigation
feat(emulators): export and import every Firestore database listed in firebase.json - #11624
Open
mokshupadhyay wants to merge 3 commits into
Open
mokshupadhyay wants to merge 3 commits into
mokshupadhyay wants to merge 3 commits into
Conversation
emulators:export and --export-on-exit only exported the (default) database. Export each database declared in the firestore config into its own folder (firestore_export_<id>) and record them in the export metadata under firestore.databases. The (default) database still goes to firestore_export, and metadata without named databases is unchanged.
--import only restored the (default) database. After the Firestore emulator starts, import each database recorded in firestore.databases of the export metadata through the emulator's :import endpoint.
Contributor
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
Author
|
Hi @joehan, a friendly ping: this is ready for review whenever you have time. Happy to adjust anything. Thanks! |
…estore-databases # Conflicts: # CHANGELOG.md
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #9665. As suggested in the issue, the Firestore emulator export now covers every database that is declared in
firebase.json, not only(default), and--importrestores them.emulators:exportand--export-on-exit): the(default)database is still exported tofirestore_export/, unchanged. Each named database listed in thefirestoreconfig (single object or array) is exported to its own folder,firestore_export_<id>/. The id is made filesystem-safe and folder names are de-duplicated case-insensitively, because two exports with the sameexport_nameoverwrite each other.firebase-export-metadata.jsongets an optionalfirestore.databasesarray (database,path,metadata_file). It is only written when named databases exist, so the metadata of a default-only export is byte-identical to before, and old metadata imports exactly as before.(default)at startup (seed_from_export). Named databases are imported after the emulator starts, byPOST /emulator/v1/projects/<project>:importwithdatabaseandexport_directorypointing at the database's.overall_export_metadatafile.Not covered (same limit as discussed in the issue): databases that are created at runtime and not listed in
firebase.json, because the emulator has no list-databases endpoint.Open questions for you: the folder name
firestore_export_<id>and thefirestore.databasesarray (a map keyed by id would also work); whether--onlyshould narrow which databases are exported (I made export ignore it); and whether import should warn when a database in the metadata is no longer infirebase.json(it currently follows the metadata).Scenarios Tested
demo-test,firebase.jsonwith(default)andsome-database, one document written to each):emulators:export ./outproducesfirestore_export/andfirestore_export_some-database/, each with its.overall_export_metadata, and the metadata file listssome-database.--import ./outrestores both databases (both documents read back). With only the export change,(default)was restored andsome-databasecame back empty.src/emulator/hubExport.spec.ts(5 tests) and two new tests infirestoreEmulator.spec.ts. Against the original sources 6 of them fail, with the change all pass; the touched spec files plushubandcommandUtilsspecs: 31 passing, 0 failing.tsc --noEmitandprettier --checkare clean, andeslintreports 0 errors on the touched files.Not tested: the
--export-on-exitpath itself (it goes through the sameexportEmulatorData, but I only ranemulators:export),emulators:exec, Windows paths and very long database ids. I did not run the fullnpm test.Sample Commands