Spaces:
Sleeping
Sleeping
File size: 3,778 Bytes
b6154b2 9218640 b6154b2 2552437 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | from __future__ import annotations
from sqlalchemy import Float, Integer, String, Text
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
class Base(DeclarativeBase):
pass
class Product(Base):
__tablename__ = "products"
id: Mapped[str] = mapped_column(String, primary_key=True)
producto: Mapped[str] = mapped_column(String, index=True)
precio: Mapped[float] = mapped_column(Float)
cantidad: Mapped[float] = mapped_column(Float)
unidad: Mapped[str] = mapped_column(String)
fecha_caducidad: Mapped[str] = mapped_column(String, index=True)
fecha_ingreso: Mapped[str] = mapped_column(String)
fecha_produccion: Mapped[str] = mapped_column(String)
categoria: Mapped[str] = mapped_column(String, default="")
caducidad_estimada: Mapped[int] = mapped_column(Integer, default=0)
notas: Mapped[str] = mapped_column(Text, default="")
fuente: Mapped[str] = mapped_column(String, default="web")
stock_actual: Mapped[float] = mapped_column(Float)
consumido_total: Mapped[float] = mapped_column(Float, default=0)
created_at: Mapped[str] = mapped_column(String)
updated_at: Mapped[str] = mapped_column(String)
class Movement(Base):
__tablename__ = "movements"
id: Mapped[str] = mapped_column(String, primary_key=True)
product_id: Mapped[str] = mapped_column(String, index=True)
producto: Mapped[str] = mapped_column(String, index=True)
tipo: Mapped[str] = mapped_column(String)
cantidad: Mapped[float] = mapped_column(Float)
unidad: Mapped[str] = mapped_column(String)
notas: Mapped[str] = mapped_column(Text, default="")
fuente: Mapped[str] = mapped_column(String, default="")
created_at: Mapped[str] = mapped_column(String)
class TelegramUser(Base):
__tablename__ = "telegram_users"
chat_id: Mapped[str] = mapped_column(String, primary_key=True)
username: Mapped[str] = mapped_column(String, default="")
first_name: Mapped[str] = mapped_column(String, default="")
last_name: Mapped[str] = mapped_column(String, default="")
is_active: Mapped[int] = mapped_column(Integer, default=1)
updated_at: Mapped[str] = mapped_column(String)
class SyncQueue(Base):
__tablename__ = "sync_queue"
queue_key: Mapped[str] = mapped_column(String, primary_key=True)
status: Mapped[str] = mapped_column(String, default="idle")
attempts: Mapped[int] = mapped_column(Integer, default=0)
last_error: Mapped[str] = mapped_column(Text, default="")
created_at: Mapped[str] = mapped_column(String)
updated_at: Mapped[str] = mapped_column(String)
class ChatMemory(Base):
__tablename__ = "chat_memory"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
chat_id: Mapped[str] = mapped_column(String, index=True)
kind: Mapped[str] = mapped_column(String, index=True)
role: Mapped[str] = mapped_column(String, default="system")
content: Mapped[str] = mapped_column(Text)
created_at: Mapped[str] = mapped_column(String, index=True)
class PendingAction(Base):
__tablename__ = "pending_actions"
chat_id: Mapped[str] = mapped_column(String, primary_key=True)
action_type: Mapped[str] = mapped_column(String)
raw_text: Mapped[str] = mapped_column(Text, default="")
question: Mapped[str] = mapped_column(Text, default="")
created_at: Mapped[str] = mapped_column(String)
updated_at: Mapped[str] = mapped_column(String)
class ReminderDelivery(Base):
__tablename__ = "reminder_deliveries"
delivery_id: Mapped[str] = mapped_column(String, primary_key=True)
chat_id: Mapped[str] = mapped_column(String, index=True)
reminder_date: Mapped[str] = mapped_column(String, index=True)
created_at: Mapped[str] = mapped_column(String)
|