phase 3.1
This commit is contained in:
38
backend/app/database/models/board.py
Normal file
38
backend/app/database/models/board.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Board model for reference boards."""
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, String, Text
|
||||
from sqlalchemy.dialects.postgresql import JSONB, UUID
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.database.base import Base
|
||||
|
||||
|
||||
class Board(Base):
|
||||
"""Board model representing a reference board."""
|
||||
|
||||
__tablename__ = "boards"
|
||||
|
||||
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)
|
||||
title = Column(String(255), nullable=False)
|
||||
description = Column(Text, nullable=True)
|
||||
viewport_state = Column(
|
||||
JSONB,
|
||||
nullable=False,
|
||||
default={"x": 0, "y": 0, "zoom": 1.0, "rotation": 0}
|
||||
)
|
||||
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
is_deleted = Column(Boolean, nullable=False, default=False)
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", back_populates="boards")
|
||||
board_images = relationship("BoardImage", back_populates="board", cascade="all, delete-orphan")
|
||||
groups = relationship("Group", back_populates="board", cascade="all, delete-orphan")
|
||||
share_links = relationship("ShareLink", back_populates="board", cascade="all, delete-orphan")
|
||||
comments = relationship("Comment", back_populates="board", cascade="all, delete-orphan")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Board(id={self.id}, title={self.title})>"
|
||||
|
||||
Reference in New Issue
Block a user