vinindkoeb/app/models/wine_category.py
carsten d2abe70333 Define core domain models and add first Alembic migration
Nine SQLModel table models covering the Organization/Route hierarchy
(WineCategory, Organization, User, Route, Participant, PurchaseRound,
WineOffering, Order, OrderLine), with explicit tablenames, FK cascade
behavior, and a CHECK constraint preventing a PurchaseRound from
reaching open/closed status without its opens_at/order_deadline_at/
pickup_at dates set. Also fixes the Alembic script template to import
sqlmodel (needed for autogenerate's AutoString column type).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-27 18:51:04 +02:00

19 lines
531 B
Python

from typing import TYPE_CHECKING, List, Optional
from sqlmodel import Field, Relationship, SQLModel
if TYPE_CHECKING:
from app.models.wine_offering import WineOffering
class WineCategoryBase(SQLModel):
name: str = Field(unique=True, index=True)
sort_order: int = Field(default=0)
class WineCategory(WineCategoryBase, table=True):
__tablename__ = "wine_category"
id: Optional[int] = Field(default=None, primary_key=True)
wine_offerings: List["WineOffering"] = Relationship(back_populates="category")