
- Add complete CRUD operations for task management - Implement task filtering by status, priority, and search - Add task statistics endpoint for summary data - Configure SQLite database with Alembic migrations - Set up FastAPI with CORS support and API documentation - Include health check endpoint and base URL information - Add comprehensive README with API usage examples - Structure project with proper separation of concerns
29 lines
942 B
Python
29 lines
942 B
Python
from sqlalchemy import Column, Integer, String, DateTime, Enum, Text
|
|
from sqlalchemy.sql import func
|
|
import enum
|
|
from app.db.base import Base
|
|
|
|
|
|
class TaskStatus(str, enum.Enum):
|
|
PENDING = "pending"
|
|
IN_PROGRESS = "in_progress"
|
|
COMPLETED = "completed"
|
|
|
|
|
|
class TaskPriority(str, enum.Enum):
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
|
|
|
|
class Task(Base):
|
|
__tablename__ = "tasks"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String(255), nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
status = Column(Enum(TaskStatus), default=TaskStatus.PENDING, nullable=False)
|
|
priority = Column(Enum(TaskPriority), default=TaskPriority.MEDIUM, nullable=False)
|
|
due_date = Column(DateTime, nullable=True)
|
|
created_at = Column(DateTime, default=func.now(), nullable=False)
|
|
updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), nullable=False) |