
Create a full-featured task management API with the following components: - RESTful CRUD operations for tasks - Task status and priority management - SQLite database with SQLAlchemy ORM - Alembic migrations - Health check endpoint - Comprehensive API documentation
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
"""
|
|
Task model definition.
|
|
"""
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
|
|
from sqlalchemy import Column, DateTime, Enum as SQLAlchemyEnum, Integer, String, Text
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class TaskStatus(str, Enum):
|
|
"""
|
|
Task status enumeration.
|
|
"""
|
|
TODO = "todo"
|
|
IN_PROGRESS = "in_progress"
|
|
DONE = "done"
|
|
|
|
|
|
class TaskPriority(str, Enum):
|
|
"""
|
|
Task priority enumeration.
|
|
"""
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
|
|
|
|
class Task(Base):
|
|
"""
|
|
Task model.
|
|
"""
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String(255), nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
status = Column(SQLAlchemyEnum(TaskStatus), default=TaskStatus.TODO, nullable=False)
|
|
priority = Column(SQLAlchemyEnum(TaskPriority), default=TaskPriority.MEDIUM, nullable=False)
|
|
due_date = Column(DateTime, nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
|
updated_at = Column(
|
|
DateTime,
|
|
default=datetime.utcnow,
|
|
onupdate=datetime.utcnow,
|
|
nullable=False
|
|
) |