
- Add user authentication with JWT tokens - Implement task CRUD operations with status and priority - Set up SQLite database with SQLAlchemy ORM - Create Alembic migrations for database schema - Add comprehensive API documentation - Include health check endpoint and CORS configuration - Structure codebase with proper separation of concerns
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
from sqlalchemy import (
|
|
Column,
|
|
Integer,
|
|
String,
|
|
Text,
|
|
Boolean,
|
|
DateTime,
|
|
ForeignKey,
|
|
Enum,
|
|
)
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.db.base import Base
|
|
import enum
|
|
|
|
|
|
class TaskStatus(enum.Enum):
|
|
PENDING = "pending"
|
|
IN_PROGRESS = "in_progress"
|
|
COMPLETED = "completed"
|
|
CANCELLED = "cancelled"
|
|
|
|
|
|
class TaskPriority(enum.Enum):
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
URGENT = "urgent"
|
|
|
|
|
|
class Task(Base):
|
|
__tablename__ = "tasks"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String, nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
status = Column(Enum(TaskStatus), default=TaskStatus.PENDING)
|
|
priority = Column(Enum(TaskPriority), default=TaskPriority.MEDIUM)
|
|
is_completed = Column(Boolean, default=False)
|
|
due_date = Column(DateTime(timezone=True), nullable=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
owner_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
|
|
owner = relationship("User", back_populates="tasks")
|