Spaces:
Sleeping
Sleeping
| 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) | |