Files
serv_benchmark/backend/app/models/document.py
Gilles Soulier c67befc549 addon
2026-01-05 16:08:01 +01:00

31 lines
1.1 KiB
Python
Executable File

"""
Linux BenchTools - Document Model
"""
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from datetime import datetime
from app.db.base import Base
class Document(Base):
"""
Uploaded documents associated with a device
"""
__tablename__ = "documents"
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
device_id = Column(Integer, ForeignKey("devices.id"), nullable=False, index=True)
doc_type = Column(String(50), nullable=False) # manual, warranty, invoice, photo, other
filename = Column(String(255), nullable=False)
stored_path = Column(String(512), nullable=False)
mime_type = Column(String(100), nullable=False)
size_bytes = Column(Integer, nullable=False)
uploaded_at = Column(DateTime, nullable=False, default=datetime.utcnow)
# Relationships
device = relationship("Device", back_populates="documents")
def __repr__(self):
return f"<Document(id={self.id}, device_id={self.device_id}, filename='{self.filename}')>"