
- Add advanced search filters (year range, score, studio, source) - Create detailed statistics endpoint for anime collection - Implement enhanced pagination metadata for better navigation - Add sorting options for search results - Enhance anime model with additional fields (season info, ratings, etc.) - Add ability to search anime by character attributes - Create migration for new anime model fields - Update README with detailed documentation of new features
60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
"""Enhance anime model
|
|
|
|
Revision ID: 5c8f9a3e9d25
|
|
Revises: 9a87c5ed9d12
|
|
Create Date: 2023-10-19 00:00:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import sqlite
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '5c8f9a3e9d25'
|
|
down_revision = '9a87c5ed9d12'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Add new fields to the anime table
|
|
with op.batch_alter_table('anime') as batch_op:
|
|
# Season information
|
|
batch_op.add_column(sa.Column('season', sa.String(20), nullable=True))
|
|
batch_op.add_column(sa.Column('season_year', sa.Integer(), nullable=True))
|
|
|
|
# Rating details
|
|
batch_op.add_column(sa.Column('score_count', sa.Integer(), nullable=True))
|
|
batch_op.add_column(sa.Column('favorites_count', sa.Integer(), nullable=True))
|
|
|
|
# Additional metadata
|
|
batch_op.add_column(sa.Column('broadcast_day', sa.String(20), nullable=True))
|
|
batch_op.add_column(sa.Column('broadcast_time', sa.String(20), nullable=True))
|
|
batch_op.add_column(sa.Column('is_airing', sa.Boolean(), nullable=True))
|
|
batch_op.add_column(sa.Column('licensors', sa.String(255), nullable=True))
|
|
batch_op.add_column(sa.Column('producers', sa.String(255), nullable=True))
|
|
|
|
# JSON field for related anime info (using SQLite-compatible JSON)
|
|
batch_op.add_column(sa.Column('related_anime', sqlite.JSON(), nullable=True))
|
|
|
|
# Content tags
|
|
batch_op.add_column(sa.Column('themes', sa.String(255), nullable=True))
|
|
batch_op.add_column(sa.Column('demographics', sa.String(100), nullable=True))
|
|
|
|
|
|
def downgrade() -> None:
|
|
# Remove all the new fields
|
|
with op.batch_alter_table('anime') as batch_op:
|
|
batch_op.drop_column('demographics')
|
|
batch_op.drop_column('themes')
|
|
batch_op.drop_column('related_anime')
|
|
batch_op.drop_column('producers')
|
|
batch_op.drop_column('licensors')
|
|
batch_op.drop_column('is_airing')
|
|
batch_op.drop_column('broadcast_time')
|
|
batch_op.drop_column('broadcast_day')
|
|
batch_op.drop_column('favorites_count')
|
|
batch_op.drop_column('score_count')
|
|
batch_op.drop_column('season_year')
|
|
batch_op.drop_column('season') |