"""Entry point for running migrations: python -m app.migrations.run"""
import asyncio

from app.core.database import close_mongo_connection, connect_to_mongo
from app.migrations.migrator import MigrationManager


async def main() -> None:
    await connect_to_mongo()
    try:
        mgr = MigrationManager()
        applied = await mgr.migrate_up()
        if applied:
            print(f"Applied {len(applied)} migration(s): {applied}")
        else:
            print("Already up to date — no pending migrations.")
    finally:
        await close_mongo_connection()


if __name__ == "__main__":
    asyncio.run(main())
