| from __future__ import annotations |
|
|
| from datetime import date |
|
|
| from sqlalchemy import Date, Enum as SAEnum, ForeignKey, Integer, String, Text |
| from sqlalchemy.orm import Mapped, mapped_column |
|
|
| from .base import Base, CaseStatus, CaseType, TimestampMixin |
|
|
|
|
| class Case(Base, TimestampMixin): |
| """A lost or found case (spec §7.4).""" |
|
|
| __tablename__ = "cases" |
|
|
| id: Mapped[int] = mapped_column(primary_key=True) |
| |
| person_id: Mapped[int | None] = mapped_column( |
| ForeignKey("users.id"), nullable=True, index=True |
| ) |
| |
| finder_name: Mapped[str | None] = mapped_column(String(120), nullable=True) |
| finder_email: Mapped[str | None] = mapped_column(String(255), nullable=True) |
| finder_phone: Mapped[str | None] = mapped_column(String(40), nullable=True) |
|
|
| known_dog_id: Mapped[int | None] = mapped_column( |
| ForeignKey("known_dogs.id"), nullable=True |
| ) |
| unknown_dog_id: Mapped[int | None] = mapped_column( |
| ForeignKey("unknown_dogs.id"), nullable=True |
| ) |
|
|
| type: Mapped[CaseType] = mapped_column(SAEnum(CaseType, native_enum=False)) |
| event_zip: Mapped[str] = mapped_column(String(10), index=True) |
| event_date: Mapped[date] = mapped_column(Date) |
| current_location: Mapped[str | None] = mapped_column(String(255), nullable=True) |
| |
| search_radius_miles: Mapped[int] = mapped_column(Integer, default=0) |
| notes: Mapped[str | None] = mapped_column(Text, nullable=True) |
| status: Mapped[CaseStatus] = mapped_column( |
| SAEnum(CaseStatus, native_enum=False), default=CaseStatus.open |
| ) |
|
|