Automated Action d60767d0ba Add categories and tags features
- Create Category and Tag models
- Create TodoTag association table
- Add category_id to Todo model
- Create Alembic migration for new tables
- Create schemas for Category and Tag
- Update Todo schemas to include Category and Tags
- Create CRUD operations for Categories and Tags
- Update Todo CRUD operations to handle categories and tags
- Create API endpoints for categories and tags
- Update Todo API endpoints with category and tag filtering
- Update documentation
2025-06-17 02:52:26 +00:00

24 lines
750 B
Python

from sqlalchemy import Column, ForeignKey, Integer, String, Table
from sqlalchemy.orm import relationship
from app.db.base import Base
# Association table for many-to-many relationship between Todo and Tag
todo_tag = Table(
"todo_tag",
Base.metadata,
Column("todo_id", Integer, ForeignKey("todos.id"), primary_key=True),
Column("tag_id", Integer, ForeignKey("tags.id"), primary_key=True),
)
class Tag(Base):
__tablename__ = "tags"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, index=True, unique=True)
owner_id = Column(Integer, ForeignKey("users.id"))
owner = relationship("User", back_populates="tags")
todos = relationship("Todo", secondary=todo_tag, back_populates="tags")