42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, Float, Integer, String, Text
|
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
class AlertRecord(Base):
|
|
__tablename__ = "alerts"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
symbol: Mapped[str] = mapped_column(String(32), index=True)
|
|
chain: Mapped[str] = mapped_column(String(32), index=True)
|
|
trigger_types: Mapped[str] = mapped_column(String(255))
|
|
score: Mapped[float] = mapped_column(Float)
|
|
details_json: Mapped[str] = mapped_column(Text)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, index=True)
|
|
|
|
|
|
class RuntimeLog(Base):
|
|
__tablename__ = "runtime_logs"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
level: Mapped[str] = mapped_column(String(12), index=True)
|
|
message: Mapped[str] = mapped_column(Text)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, index=True)
|
|
|
|
|
|
class KvStore(Base):
|
|
"""Simple key-value settings persisted in SQLite (e.g. chart bar from web UI)."""
|
|
|
|
__tablename__ = "kv_store"
|
|
|
|
key: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
value: Mapped[str] = mapped_column(Text)
|
|
updated_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|