
This commit implements a simple movie database backend inspired by IMDb. It includes: - API endpoints for movies, actors, directors and genres - SQLAlchemy models with relationships - Alembic migrations - Pydantic schemas for request/response validation - Search and filtering functionality - Health check endpoint - Complete documentation
22 lines
918 B
Python
22 lines
918 B
Python
from sqlalchemy import Column, Integer, String, Date, Float, Text, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class Movie(Base):
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String(255), nullable=False, index=True)
|
|
release_date = Column(Date, nullable=True)
|
|
overview = Column(Text, nullable=True)
|
|
poster_path = Column(String(255), nullable=True)
|
|
runtime = Column(Integer, nullable=True) # in minutes
|
|
rating = Column(Float, nullable=True) # e.g., 8.5
|
|
|
|
# Relationships
|
|
director_id = Column(Integer, ForeignKey("director.id"), nullable=True)
|
|
director = relationship("Director", back_populates="movies")
|
|
|
|
# Many-to-many relationships
|
|
actors = relationship("Actor", secondary="movieactor", back_populates="movies")
|
|
genres = relationship("Genre", secondary="moviegenre", back_populates="movies") |