
- Set up project structure with FastAPI, SQLAlchemy, and Alembic - Create database models for User and Item - Implement CRUD operations for all models - Create API endpoints with validation - Add health check endpoint - Configure CORS middleware - Set up database migrations - Add comprehensive documentation in README
17 lines
630 B
Python
17 lines
630 B
Python
from sqlalchemy import Column, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql.sqltypes import DateTime
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.database.base_class import Base
|
|
|
|
|
|
class Item(Base):
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String, index=True)
|
|
description = Column(Text)
|
|
owner_id = Column(Integer, ForeignKey("user.id"))
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
owner = relationship("User", back_populates="items") |