Added migrations

This commit is contained in:
2023-08-18 20:43:09 +02:00
parent 32260e95a7
commit 24a2837f34
5 changed files with 62 additions and 19 deletions

22
modules/migrator.py Normal file
View File

@@ -0,0 +1,22 @@
from typing import Any, Mapping
from libbot.sync import config_get
from mongodb_migrations.cli import MigrationManager
from mongodb_migrations.config import Configuration
def migrate_database() -> None:
"""Apply migrations from folder `migrations/` to the database"""
db_config: Mapping[str, Any] = config_get("database")
manager_config = Configuration(
{
"mongo_host": db_config["host"],
"mongo_port": db_config["port"],
"mongo_database": db_config["name"],
"mongo_username": db_config["user"],
"mongo_password": db_config["password"],
}
)
manager = MigrationManager(manager_config)
manager.run()