- Create organizations table with Alembic migration (3-phase: create table, migrate data, drop old column) - Add org_id FK on championships linking to organizations - Refactor all schemas into one-class-per-file packages (auth, championship, organization, participant, registration, user) - Update CRUD layer with selectinload for organization relationships - Update frontend types and components to use nested organization object - Remove phantom Championship fields (subtitle, venue, accent_color) from frontend Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
12 lines
360 B
Python
12 lines
360 B
Python
import uuid
|
|
|
|
from sqlalchemy import select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.models.organization import Organization
|
|
|
|
|
|
async def get_by_user_id(db: AsyncSession, user_id: uuid.UUID) -> Organization | None:
|
|
result = await db.execute(select(Organization).where(Organization.user_id == user_id))
|
|
return result.scalar_one_or_none()
|