-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-mongo.js
More file actions
35 lines (28 loc) · 943 Bytes
/
Copy pathinit-mongo.js
File metadata and controls
35 lines (28 loc) · 943 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
// MongoDB initialization script
// This script runs when the MongoDB container starts
// Switch to the hyperlogic_ai database
db = db.getSiblingDB('hyperlogic_ai');
// Create a user for the application
db.createUser({
user: 'hyperlogic',
pwd: 'password',
roles: [
{
role: 'readWrite',
db: 'hyperlogic_ai'
}
]
});
// Create collections with indexes for better performance
db.createCollection('conversations');
db.createCollection('messages');
db.createCollection('embeddings');
// Create indexes
db.conversations.createIndex({ "user_id": 1 });
db.conversations.createIndex({ "created_at": -1 });
db.conversations.createIndex({ "title": "text" });
db.messages.createIndex({ "conversation_id": 1 });
db.messages.createIndex({ "created_at": -1 });
db.embeddings.createIndex({ "conversation_id": 1 });
db.embeddings.createIndex({ "vector": "2dsphere" });
print('MongoDB initialization completed successfully!');