Automated Action e35edd0f6a Add database models and SQLAlchemy setup for todo app
- Created app directory structure with db, models, and schemas modules
- Added SQLAlchemy Base class in app/db/base.py to prevent circular imports
- Implemented database session setup with SQLite configuration
- Created Todo model with id, title, description, completed, created_at, updated_at fields
- Added Pydantic schemas for TodoCreate, TodoUpdate, and TodoResponse
- Added requirements.txt with FastAPI, SQLAlchemy, and other dependencies
2025-06-19 00:41:31 +00:00

15 lines
600 B
Python

from datetime import datetime
from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime
from app.db.base import Base
class Todo(Base):
__tablename__ = "todos"
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
title = Column(String(200), nullable=False, index=True)
description = Column(Text, nullable=True)
completed = Column(Boolean, default=False, nullable=False)
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)