
- Implemented CRUD operations for task management - Added task status tracking (pending, in_progress, completed) - Included priority levels (low, medium, high) - Set up SQLite database with Alembic migrations - Added filtering and pagination support - Configured CORS for all origins - Included health check endpoint - Added comprehensive API documentation - Formatted code with Ruff linting
31 lines
926 B
Python
31 lines
926 B
Python
from sqlalchemy import Column, Integer, String, Text, DateTime, Enum
|
|
from sqlalchemy.sql import func
|
|
from enum import Enum as PyEnum
|
|
from app.db.base import Base
|
|
|
|
|
|
class TaskStatus(PyEnum):
|
|
PENDING = "pending"
|
|
IN_PROGRESS = "in_progress"
|
|
COMPLETED = "completed"
|
|
|
|
|
|
class TaskPriority(PyEnum):
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
|
|
|
|
class Task(Base):
|
|
__tablename__ = "tasks"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String(200), 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)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(
|
|
DateTime(timezone=True), onupdate=func.now(), server_default=func.now()
|
|
)
|