Fuego

Managing Document and Collection Renaming in Firestore

big-idea

Renaming a Document

Renaming a document in Firestore involves creating a new document with the updated ID while copying the data from the original document. The original document is then deleted. However, note that any references to the original document ID will not be updated automatically.

Steps to Rename a Document:

  1. Select the document you want to rename.
  2. Open the context menu by selecting the document or right-clicking on its ID.
  3. Choose Rename document.
  4. Enter the new document ID (it must be different from the current one).
  5. Confirm the action.

Important Considerations:

  • A new document is created with the new ID, including all subcollections.
  • The original document is deleted after copying the data.
  • Any external references to the document ID must be manually updated.

Renaming a Collection

Firestore does not support direct renaming of collections. Instead, the system copies documents to a new collection and deletes the old one progressively.

Steps to Rename a Collection:

  1. Open the Tools menu.
  2. Select Rename collection.
  3. Enter the new collection name.
  4. Choose whether to enable Progressive document deletion.
  5. Confirm the action.

Important Considerations:

  • The renaming process involves creating a new collection and copying all documents.
  • If interrupted, you may end up with two incomplete collections.
  • Progressive deletion removes documents as they are copied, allowing resumption if interrupted.
  • Manual updates are required for references to the old collection name.
CAUTION

These functionalities ensure flexibility in managing Firestore data while maintaining data integrity. However, references to documents stored within the renamed document will not be updated automatically, which may cause them to become invalid after renaming.