Files
webref/backend/app/database/models/image.py
Danilo Reyes b55ac51fe2 feat: add unified linting scripts and git hooks for code quality enforcement
- Introduced `lint` and `lint-fix` applications in `flake.nix` for unified linting of backend (Python) and frontend (TypeScript/Svelte) code.
- Added `scripts/lint.sh` for manual linting execution.
- Created `scripts/install-hooks.sh` to set up git hooks for automatic linting before commits and optional tests before pushes.
- Updated `README.md` with instructions for using the new linting features and git hooks.
2025-11-02 00:08:37 -06:00

36 lines
1.3 KiB
Python

"""Image model for uploaded images."""
import uuid
from datetime import datetime
from sqlalchemy import BigInteger, Column, DateTime, ForeignKey, Integer, String
from sqlalchemy.dialects.postgresql import JSONB, UUID
from sqlalchemy.orm import relationship
from app.database.base import Base
class Image(Base):
"""Image model representing uploaded image files."""
__tablename__ = "images"
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
user_id = Column(UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True)
filename = Column(String(255), nullable=False, index=True)
storage_path = Column(String(512), nullable=False)
file_size = Column(BigInteger, nullable=False)
mime_type = Column(String(100), nullable=False)
width = Column(Integer, nullable=False)
height = Column(Integer, nullable=False)
image_metadata = Column(JSONB, nullable=False)
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
reference_count = Column(Integer, nullable=False, default=0)
# Relationships
user = relationship("User", back_populates="images")
board_images = relationship("BoardImage", back_populates="image", cascade="all, delete-orphan")
def __repr__(self) -> str:
return f"<Image(id={self.id}, filename={self.filename})>"