feat: preserve gear components through catch imports
CI / backend-and-migrations (push) Waiting to run
CI / astro-build (push) Waiting to run
CI / dependency-audit (push) Waiting to run
CI / compose-e2e (push) Waiting to run

This commit is contained in:
ik
2026-09-20 18:10:41 +07:00
parent 4e9895fbf4
commit 4f0c2d23de
15 changed files with 379 additions and 7 deletions
+28
View File
@@ -165,6 +165,34 @@ class CatchReport(Base):
spot: Mapped[Spot | None] = relationship()
waterbody: Mapped[Waterbody] = relationship()
bait: Mapped[Bait | None] = relationship()
tackle_components: Mapped[list["CatchTackleComponent"]] = relationship(back_populates="catch_report")
class CatchTackleComponent(Base):
"""Ordered gear evidence; unresolved raw values are valid and preserved."""
__tablename__ = "catch_tackle_component"
__table_args__ = (
UniqueConstraint("catch_report_id", "position"),
CheckConstraint(
"NOT (tackle_item_id IS NOT NULL AND rig_id IS NOT NULL)",
name="ck_catch_tackle_one_canonical_target",
),
)
id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
catch_report_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("catch_report.id"))
tackle_item_id: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("tackle_item.id"))
rig_id: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("rig.id"))
role: Mapped[str] = mapped_column(String(50))
position: Mapped[int] = mapped_column(Integer)
raw_value: Mapped[str] = mapped_column(String(200))
source_system: Mapped[str | None] = mapped_column(String(50))
source_external_id: Mapped[str | None] = mapped_column(String(200))
source_url: Mapped[str | None] = mapped_column(Text)
raw_payload: Mapped[dict | None] = mapped_column(JSON)
catch_report: Mapped[CatchReport] = relationship(back_populates="tackle_components")
tackle_item: Mapped[TackleItem | None] = relationship()
rig: Mapped[Rig | None] = relationship()
class OfficialRecordImport(Base):