Updating a collection name in Cloud Firestore

It's not possible to change the names or IDs or collections or documents once they exist. All that data is immutable, for the purpose of building efficient indexes.

You could certainly read everything out, then put it all back in with new names and IDs.


You can load it then reupload it with the new name

      await FirebaseFirestore.instance
          .collection(oldCollectionName)
          .get()
          .then((QuerySnapshot snapShot) async {
        snapShot.docs.forEach((element) async {
          await FirebaseFirestore.instance
              .collection(newCollectionName)
              .doc(element.id)
              .set(element.data()as Map<String, dynamic>);
        });
      });

Note: the above code is written for flutter, but it might help anyone with little changes.