chore: save session state – feature/phase-1 ready to implement
- Update session-context.md with exact resume point for next session - Update settings.local.json with broader git permissions - feature/grundstruktur merged to develop - PAT authentication configured Version: 0.2.3
This commit is contained in:
66
backend/app/models/bed.py
Normal file
66
backend/app/models/bed.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import enum
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, Enum, ForeignKey, Numeric, String, Text, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.db.base import Base
|
||||
|
||||
|
||||
class LocationType(str, enum.Enum):
|
||||
SONNIG = "sonnig"
|
||||
HALBSCHATTEN = "halbschatten"
|
||||
SCHATTEN = "schatten"
|
||||
|
||||
|
||||
class SoilType(str, enum.Enum):
|
||||
NORMAL = "normal"
|
||||
SANDIG = "sandig"
|
||||
LEHMIG = "lehmig"
|
||||
HUMUSREICH = "humusreich"
|
||||
|
||||
|
||||
class Bed(Base):
|
||||
__tablename__ = "beds"
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(
|
||||
primary_key=True, default=uuid.uuid4, index=True
|
||||
)
|
||||
tenant_id: Mapped[uuid.UUID] = mapped_column(
|
||||
ForeignKey("tenants.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
width_m: Mapped[float] = mapped_column(Numeric(5, 2), nullable=False)
|
||||
length_m: Mapped[float] = mapped_column(Numeric(5, 2), nullable=False)
|
||||
location: Mapped[LocationType] = mapped_column(
|
||||
Enum(LocationType, name="location_type"),
|
||||
nullable=False,
|
||||
)
|
||||
soil_type: Mapped[SoilType] = mapped_column(
|
||||
Enum(SoilType, name="soil_type"),
|
||||
nullable=False,
|
||||
default=SoilType.NORMAL,
|
||||
)
|
||||
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
server_default=func.now(),
|
||||
nullable=False,
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
server_default=func.now(),
|
||||
onupdate=lambda: datetime.now(timezone.utc),
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
# Relationships
|
||||
tenant: Mapped["Tenant"] = relationship("Tenant", back_populates="beds") # noqa: F821
|
||||
plantings: Mapped[list["BedPlanting"]] = relationship( # noqa: F821
|
||||
"BedPlanting", back_populates="bed", cascade="all, delete-orphan"
|
||||
)
|
||||
Reference in New Issue
Block a user