Automated Action 606cda0912 Implement Blogging API with FastAPI and SQLite
- Create project structure with app organization
- Set up FastAPI application with CORS and health endpoint
- Implement database models with SQLAlchemy (User, Post, Comment)
- Set up Alembic for database migrations
- Implement authentication with JWT tokens
- Create CRUD operations for all models
- Implement REST API endpoints for users, posts, and comments
- Add comprehensive documentation in README.md
2025-06-02 22:34:58 +00:00

17 lines
717 B
Python

from datetime import datetime
from sqlalchemy import Column, String, Text, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from app.db.base_class import Base
class Comment(Base):
id = Column(String, primary_key=True, index=True)
content = Column(Text, nullable=False)
post_id = Column(String, ForeignKey("post.id"), nullable=False)
author_id = Column(String, ForeignKey("user.id"), nullable=False)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
# Relationships
post = relationship("Post", back_populates="comments")
author = relationship("User", back_populates="comments")