
- 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
24 lines
707 B
Python
24 lines
707 B
Python
from enum import Enum as PyEnum
|
|
from sqlalchemy import Boolean, Column, Integer, String, Enum
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class UserRole(str, PyEnum):
|
|
ADMIN = "admin"
|
|
USER = "user"
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True)
|
|
hashed_password = Column(String)
|
|
is_active = Column(Boolean, default=True)
|
|
role = Column(Enum(UserRole), default=UserRole.USER)
|
|
|
|
todos = relationship("Todo", back_populates="owner")
|
|
categories = relationship("Category", back_populates="owner")
|
|
tags = relationship("Tag", back_populates="owner") |