
This commit includes: - Project structure and configuration - Database models for tasks, users, and categories - Authentication system with JWT - CRUD endpoints for tasks and categories - Search, filter, and sorting functionality - Health check endpoint - Alembic migration setup - Documentation
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from sqlalchemy import (
|
|
Boolean,
|
|
Column,
|
|
DateTime,
|
|
ForeignKey,
|
|
Integer,
|
|
String,
|
|
Text,
|
|
)
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class Task(Base):
|
|
__tablename__ = "tasks"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String, index=True, nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
is_completed = Column(Boolean, default=False)
|
|
due_date = Column(DateTime(timezone=True), nullable=True)
|
|
priority = Column(String, default="medium") # low, medium, high
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
# Foreign keys
|
|
owner_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
category_id = Column(Integer, ForeignKey("categories.id"), nullable=True)
|
|
|
|
# Relationships
|
|
owner = relationship("User", back_populates="tasks")
|
|
category = relationship("Category", back_populates="tasks")
|