
- Add proper model relationships for better querying - Implement character model and endpoints for managing anime characters - Add advanced filtering options (year, score range, source, studio, etc.) - Add statistics endpoint for analyzing anime collection - Include pagination metadata for easier navigation - Create Alembic migration for the new character model - Update README with new features and documentation
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, Text, ForeignKey, Date
|
|
from sqlalchemy.orm import relationship
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class Character(Base):
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(255), index=True, nullable=False)
|
|
role = Column(String(50), nullable=True) # Main, Supporting, Antagonist
|
|
description = Column(Text, nullable=True)
|
|
voice_actor = Column(String(255), nullable=True)
|
|
image_url = Column(String(255), nullable=True)
|
|
anime_id = Column(Integer, ForeignKey("anime.id", ondelete="CASCADE"), nullable=False)
|
|
|
|
# Additional character details
|
|
age = Column(String(50), nullable=True) # Can be a range or "Unknown"
|
|
gender = Column(String(50), nullable=True)
|
|
birth_date = Column(Date, nullable=True)
|
|
height = Column(String(50), nullable=True) # in cm
|
|
weight = Column(String(50), nullable=True) # in kg
|
|
blood_type = Column(String(10), nullable=True)
|
|
popularity_rank = Column(Integer, nullable=True)
|
|
|
|
# Relationships
|
|
anime = relationship("Anime", back_populates="characters") |