
- 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
20 lines
921 B
Python
20 lines
921 B
Python
from datetime import datetime
|
|
from sqlalchemy import Boolean, Column, String, DateTime
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base_class import Base
|
|
|
|
class User(Base):
|
|
id = Column(String, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
username = Column(String, unique=True, index=True, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
full_name = Column(String, index=True)
|
|
is_active = Column(Boolean(), default=True)
|
|
is_superuser = Column(Boolean(), default=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
# Relationships
|
|
posts = relationship("Post", back_populates="author", cascade="all, delete-orphan")
|
|
comments = relationship("Comment", back_populates="author", cascade="all, delete-orphan") |