from sqlalchemy import Column, ForeignKey, Integer, String, Text
from sqlalchemy.orm import relationship
from app.api.db.database import Base

class Tags(Base):
    __tablename__ = 'tags'

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String, nullable=False, unique=True)
    description = Column(Text, nullable=True)

    posts = relationship("Post", back_populates="tags", secondary="post_tags")

    def __repr__(self):
        return f"Tag(id={self.id}, name='{self.name}', description='{self.description}')"