diff --git a/alembic/env.py b/alembic/env.py index b15956f..3183f03 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -28,6 +28,8 @@ from media_manager.auth.db import User, OAuthAccount # noqa: E402 from media_manager.indexer.models import IndexerQueryResult # noqa: E402 from media_manager.torrent.models import Torrent # noqa: E402 from media_manager.tv.models import Show, Season, Episode, SeasonFile, SeasonRequest # noqa: E402 +from media_manager.movies.models import Movie, MovieFile, MovieRequest # noqa: E402 +from media_manager.notification.models import Notification # noqa: E402 from media_manager.database import Base # noqa: E402 @@ -45,6 +47,10 @@ target_metadata = Base.metadata Episode, SeasonFile, SeasonRequest, + Movie, + MovieFile, + MovieRequest, + Notification, ) @@ -112,6 +118,12 @@ def run_migrations_online() -> None: and associate a connection with the context. """ + + def include_object(object, name, type_, reflected, compare_to): + if type_ == "table" and name == "apscheduler_jobs": + return False + return True + connectable = engine_from_config( config.get_section(config.config_ini_section, {}), prefix="sqlalchemy.", @@ -119,7 +131,11 @@ def run_migrations_online() -> None: ) with connectable.connect() as connection: - context.configure(connection=connection, target_metadata=target_metadata) + context.configure( + connection=connection, + target_metadata=target_metadata, + include_object=include_object, + ) with context.begin_transaction(): context.run_migrations() diff --git a/alembic/versions/21a19f0675f9_increase_access_token_length.py b/alembic/versions/21a19f0675f9_increase_access_token_length.py new file mode 100644 index 0000000..0c07a18 --- /dev/null +++ b/alembic/versions/21a19f0675f9_increase_access_token_length.py @@ -0,0 +1,45 @@ +"""increase_access_token_length + +Revision ID: 21a19f0675f9 +Revises: 1f340754640a +Create Date: 2025-07-06 10:49:08.814496 + +""" + +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = "21a19f0675f9" +down_revision: Union[str, None] = "1f340754640a" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + """Upgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column( + "oauth_account", + "access_token", + existing_type=sa.VARCHAR(length=1024), + type_=sa.String(length=4096), + existing_nullable=False, + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + """Downgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column( + "oauth_account", + "access_token", + existing_type=sa.String(length=4096), + type_=sa.VARCHAR(length=1024), + existing_nullable=False, + ) + # ### end Alembic commands ### diff --git a/media_manager/auth/db.py b/media_manager/auth/db.py index bfb612e..f6a4e8e 100644 --- a/media_manager/auth/db.py +++ b/media_manager/auth/db.py @@ -6,14 +6,16 @@ from fastapi_users.db import ( SQLAlchemyUserDatabase, SQLAlchemyBaseOAuthAccountTableUUID, ) +from sqlalchemy import String from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine -from sqlalchemy.orm import Mapped, relationship +from sqlalchemy.orm import Mapped, relationship, mapped_column from media_manager.database import Base from media_manager.database import db_url class OAuthAccount(SQLAlchemyBaseOAuthAccountTableUUID, Base): + access_token: Mapped[str] = mapped_column(String(length=4096), nullable=False) pass