refactor: Add db creation as step in MCP creation

This commit is contained in:
Igor Ilic 2025-11-06 19:12:09 +01:00
parent 7dec6bfded
commit 96c8bba580
2 changed files with 5 additions and 0 deletions

View file

@ -1096,6 +1096,10 @@ async def main():
# Skip migrations when in API mode (the API server handles its own database) # Skip migrations when in API mode (the API server handles its own database)
if not args.no_migration and not args.api_url: if not args.no_migration and not args.api_url:
from cognee.modules.engine.operations.setup import setup
await setup()
# Run Alembic migrations from the main cognee directory where alembic.ini is located # Run Alembic migrations from the main cognee directory where alembic.ini is located
logger.info("Running database migrations...") logger.info("Running database migrations...")
migration_result = subprocess.run( migration_result = subprocess.run(

View file

@ -37,5 +37,6 @@ class Dataset(Base):
"createdAt": self.created_at.isoformat(), "createdAt": self.created_at.isoformat(),
"updatedAt": self.updated_at.isoformat() if self.updated_at else None, "updatedAt": self.updated_at.isoformat() if self.updated_at else None,
"ownerId": str(self.owner_id), "ownerId": str(self.owner_id),
"tenantId": str(self.tenant_id),
"data": [data.to_json() for data in self.data], "data": [data.to_json() for data in self.data],
} }