chore(quality): apply ruff autofixes and formatting (8 fixes, 18 files reformatted)
This commit is contained in:
@@ -1,18 +1,31 @@
|
||||
"""Attachment model."""
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import String, DateTime, ForeignKey, Integer, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class Attachment(Base):
|
||||
"""Attachment model."""
|
||||
__tablename__ = "attachments"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
filename = Column(String(255), nullable=False)
|
||||
filepath = Column(String(500), nullable=False)
|
||||
file_size = Column(Integer)
|
||||
mime_type = Column(String(100))
|
||||
record_id = Column(Integer, nullable=True)
|
||||
uploaded_by = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
record_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("records.id", ondelete="CASCADE"), nullable=False, index=True
|
||||
)
|
||||
column_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("columns.id", ondelete="CASCADE"), nullable=True
|
||||
)
|
||||
filename: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
file_path: Mapped[str] = mapped_column(String(500), nullable=False)
|
||||
file_size: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
|
||||
mime_type: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
uploaded_at: Mapped[datetime] = mapped_column(DateTime, default=func.now())
|
||||
|
||||
# Relationships
|
||||
record = relationship("Record", back_populates="attachments")
|
||||
column = relationship("Column", back_populates="attachments")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Attachment(id={self.id}, filename={self.filename})>"
|
||||
|
||||
Reference in New Issue
Block a user