diff --git a/backend/models.py b/backend/models.py index da28e40..69fab06 100644 --- a/backend/models.py +++ b/backend/models.py @@ -376,3 +376,23 @@ class RandomNumberOutcome(Base): created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), default=lambda: datetime.now(UTC) ) + + +class PriceHistory(Base): + """Price history records from external exchanges.""" + + __tablename__ = "price_history" + __table_args__ = ( + UniqueConstraint("source", "pair", "timestamp", name="uq_price_source_pair_ts"), + ) + + id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) + source: Mapped[str] = mapped_column(String(50), nullable=False, index=True) + pair: Mapped[str] = mapped_column(String(20), nullable=False) + price: Mapped[float] = mapped_column(Float, nullable=False) + timestamp: Mapped[datetime] = mapped_column( + DateTime(timezone=True), nullable=False, index=True + ) + created_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), default=lambda: datetime.now(UTC) + )