All checks were successful
Deploy Dev / Build (pull_request) Successful in 6s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Prod / Build (pull_request) Successful in 4s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
Deploy Prod / Push (pull_request) Successful in 8s
Deploy Prod / Deploy prod (pull_request) Successful in 8s
31 lines
872 B
Python
31 lines
872 B
Python
import os
|
|
import motor
|
|
import motor.motor_asyncio
|
|
import pymongo
|
|
|
|
|
|
MONGO_HOST = os.getenv('MONGO_HOST', 'localhost')
|
|
MONGO_PASSWORD = os.getenv('MONGO_PASSWORD', 'password')
|
|
|
|
CONNECTION_STRING = f'mongodb://mongo:{MONGO_PASSWORD}@{MONGO_HOST}:27017/'
|
|
|
|
|
|
database: 'motor.MotorDatabase' = motor.motor_asyncio.AsyncIOMotorClient(CONNECTION_STRING).configurator
|
|
|
|
def create_indexes():
|
|
client = pymongo.MongoClient(CONNECTION_STRING)
|
|
database = client.get_database('configurator')
|
|
database.get_collection('configs').create_index([
|
|
('stage', 1),
|
|
('project', 1),
|
|
('name', 1),
|
|
], unique=True)
|
|
database.get_collection('experiments').create_index([
|
|
('stage', 1),
|
|
('project', 1),
|
|
('name', 1),
|
|
], unique=True)
|
|
database.get_collection('staff').create_index([
|
|
('platform_id', 1),
|
|
], unique=True)
|