Fuego

Moving a Collection in Firestore

big-idea

Overview

The Move Collection feature in Firestore allows transferring an entire collection to another location, which can be a different database or a specific path within the same database.

Steps to Move a Collection

  1. Open the Move Panel

    • Select the collection to move.
    • Click on the Tools -> Move Collection option.
  2. Select the Target Project and Database

    • Choose a Firebase project and a different database if needed.
  3. Choose the New Path

    • The collection can be moved to the root or under an existing document.
  4. Optional: Rename the Collection

    • Enable the New name option if you want to assign a different name to the new collection.
  5. Manage Documents During the Move

    • Select the Delete documents as they are moved option if you want to remove the documents from the original location after the transfer.
    • If this option is not selected, the documents will be copied first and deleted only after all documents have been successfully copied to the new location, which results in double the number of read operations.
  6. Confirm the Operation

    • Click Confirm to start the moving process.

Firestore Limitations in Moving Collections

  • Firestore does not support atomic operations for moving collections. Documents are copied first and then deleted if the option is selected.
  • Subcollections are not automatically moved. They must be handled manually and moved separately.
  • The transfer can be slow if the collection contains many documents. Since Firestore operates in a scalable manner, each document is processed individually.

Final Considerations

CAUTION

Moving a collection in Firestore requires careful planning to avoid data loss or unwanted duplication. If dealing with very large collections, the time required for the transfer can be significant.