
- Setup project structure with FastAPI - Create Todo model and database schemas - Implement CRUD operations for Todo items - Create API endpoints for Todo operations - Add health check endpoint - Configure Alembic for database migrations - Add detailed documentation in README.md
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from datetime import datetime
|
|
from enum import Enum as PyEnum
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import Boolean, DateTime, Enum, String, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class TodoPriority(str, PyEnum):
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
|
|
|
|
class Todo(Base):
|
|
"""
|
|
Model for Todo items in the database.
|
|
"""
|
|
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
|
title: Mapped[str] = mapped_column(String(255), index=True)
|
|
description: Mapped[Optional[str]] = mapped_column(String(1000), nullable=True)
|
|
priority: Mapped[TodoPriority] = mapped_column(
|
|
Enum(TodoPriority), default=TodoPriority.MEDIUM
|
|
)
|
|
completed: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime, default=func.now(), nullable=False
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime, default=func.now(), onupdate=func.now(), nullable=False
|
|
)
|