Created
September 27, 2023 10:04
-
-
Save manniru/526d81f696c73cf4fa9f950b41cfbcc1 to your computer and use it in GitHub Desktop.
This file contains 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
import firebase_admin | |
from firebase_admin import credentials | |
from firebase_admin import firestore | |
# 1. Initialize Firebase Admin SDK | |
cred = credentials.Certificate('./e-naira-firebase-adminsdk.json') | |
firebase_admin.initialize_app(cred) | |
db = firestore.client() | |
# 2. Read all the documents from the original collection | |
old_collection = db.collection('_offline_transactions') | |
documents = old_collection.stream() | |
for doc in documents: | |
# 3. Write each of those documents to the new collection | |
new_doc_ref = db.collection('_offline_transactions1').document(doc.id) | |
new_doc_ref.set(doc.to_dict()) | |
# 4. Delete the document from the old collection | |
doc.reference.delete() | |
print("Collection renamed successfully!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment