Spaces:
Paused

miracle / scripts /create_diag_project.py
dushyantsingh0
backend stabilization
b7980f7
Raw History Blame Contribute Delete
1.38 kB
import asyncio
from core.database import async_session_factory
from models.workspace import Workspace
from models.project import Project
from sqlalchemy import select
async def create_diagnostic_project():
async with async_session_factory() as db:
# 1. Find Acme Workspace
ws_result = await db.execute(select(Workspace).where(Workspace.name == "Acme Corp"))
ws = ws_result.scalar_one_or_none()
if not ws:
# Fallback to any workspace
ws_result = await db.execute(select(Workspace).limit(1))
ws = ws_result.scalar_one_or_none()
if not ws:
print("ERROR: No workspace found. Please run seed.py first.")
return
# 2. Create Project
project = Project(
name="Nexus Many-to-Many Launch",
description="Diagnostic project to verify context-aware lookup and global visibility.",
status="active",
workspace_id=ws.id
)
db.add(project)
await db.commit()
await db.refresh(project)
print("\n--- Project Created Successfully ---")
print(f"PROJECT_ID: {project.id}")
print(f"WORKSPACE: {ws.name} ({ws.id})")
print("------------------------------------\n")
if __name__ == "__main__":
asyncio.run(create_diagnostic_project())