Spaces:
Sleeping
Sleeping
| from sqlalchemy import ( | |
| Column, String, Boolean, DateTime, Integer, | |
| Text, BigInteger, Index | |
| ) | |
| from sqlalchemy.sql import func | |
| from .base import Base | |
| class GeneratedFile(Base): | |
| __tablename__ = "generated_files" | |
| id = Column(Integer, primary_key=True) | |
| file_id = Column(String(36), unique=True, nullable=False, index=True) | |
| user_hash = Column(String(64), nullable=False, index=True) | |
| tenant_id = Column(String(64), nullable=True, index=True) | |
| file_name = Column(String(300), nullable=False) | |
| file_type = Column(String(20)) | |
| # xlsx | pdf | docx | csv | ps1 | sh | |
| file_size_bytes = Column(BigInteger, default=0) | |
| storage_path = Column(String(500)) | |
| # Context | |
| generated_for = Column(String(100)) | |
| # "P&L May 2026" | "Payroll June 2026" | |
| chat_session_id = Column(String(36), nullable=True, index=True) | |
| project_id = Column(String(36), nullable=True, index=True) | |
| # Formula version used | |
| formula_version = Column(String(50)) | |
| # Downloads | |
| download_count = Column(Integer, default=0) | |
| last_downloaded_at = Column(DateTime, nullable=True) | |
| # Retention | |
| expires_at = Column(DateTime, nullable=True) | |
| is_deleted = Column(Boolean, default=False) | |
| created_at = Column(DateTime, server_default=func.now()) | |
| __table_args__ = ( | |
| Index("ix_files_user", "user_hash"), | |
| Index("ix_files_session", "chat_session_id"), | |
| Index("ix_files_project", "project_id"), | |
| Index("ix_files_created", "created_at"), | |
| ) | |