
- Set up project structure with FastAPI - Create Todo database model and schema - Implement database connection with SQLAlchemy - Set up Alembic migrations - Implement CRUD API endpoints for Todo items - Add health check endpoint - Update documentation in README.md generated with BackendIM... (backend.im)
16 lines
641 B
Python
16 lines
641 B
Python
from sqlalchemy import Column, Integer, String, Boolean, DateTime, func
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from app.db.database import Base
|
|
|
|
class Todo(Base):
|
|
"""
|
|
Todo model for storing todo items in the database.
|
|
"""
|
|
__tablename__ = "todos"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String, index=True)
|
|
description = Column(String, nullable=True)
|
|
completed = Column(Boolean, default=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) |