from sqlalchemy import Column, String, Text, Boolean, DateTime, ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.sql import func from app.core.database import Base class Space(Base): __tablename__ = "pjctrl_spaces" id = Column(String(36), primary_key=True) name = Column(String(200), nullable=False) description = Column(Text, nullable=True) owner_id = Column(String(36), ForeignKey("pjctrl_users.id"), nullable=False) is_active = Column(Boolean, default=True, nullable=False) created_at = Column(DateTime, server_default=func.now(), nullable=False) updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), nullable=False) # Relationships owner = relationship("User", back_populates="owned_spaces") projects = relationship("Project", back_populates="space", cascade="all, delete-orphan")