from sqlalchemy import Column, String, ForeignKey, UniqueConstraint
from app.models.base import BaseModel


class Folder(BaseModel):
    __tablename__ = "folders"
    __table_args__ = (
        UniqueConstraint('user_id', 'parent_id', 'name', name='uq_user_parent_name'),
    )

    user_id = Column(String(36), ForeignKey("users.id"), nullable=False, index=True)
    name = Column(String(255), nullable=False)
    parent_id = Column(String(36), ForeignKey("folders.id"), nullable=True)
