-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore_init.py
More file actions
40 lines (36 loc) · 1022 Bytes
/
firestore_init.py
File metadata and controls
40 lines (36 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from google.cloud import firestore
# Initialize Firestore client
db = firestore.Client()
# Create sample documents to initialize collections
collections = [
{
'name': 'generations',
'sample': {
'id': 'sample',
'prompt': 'Sample generation',
'status': 'completed',
'created_at': firestore.SERVER_TIMESTAMP
}
},
{
'name': 'quality_reports',
'sample': {
'id': 'sample',
'generation_id': 'sample',
'overall_score': 0,
'created_at': firestore.SERVER_TIMESTAMP
}
},
{
'name': 'users',
'sample': {
'id': 'sample',
'created_at': firestore.SERVER_TIMESTAMP
}
}
]
for collection in collections:
doc_ref = db.collection(collection['name']).document('_init')
doc_ref.set(collection['sample'])
print(f"✓ Initialized collection: {collection['name']}")
print("\n✅ Firestore collections initialized!")