fix(migrations): connect to mongo before running migrations in run.py
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
99554173e6
commit
8a1440201e
1 changed files with 11 additions and 6 deletions
|
|
@ -1,16 +1,21 @@
|
|||
"""Entry point for running migrations: python -m app.migrations.run"""
|
||||
import asyncio
|
||||
|
||||
from app.core.database import connect_to_mongo, close_mongo_connection
|
||||
from app.migrations.migrator import MigrationManager
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
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.")
|
||||
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__":
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue