mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-25 18:25:35 +02:00
Merge pull request #36 from maxdorninger/increase-max-access-token-length-supported
Increase max access and refresh token length supported
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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 ###
|
||||
@@ -0,0 +1,45 @@
|
||||
"""increase_refresh_token_length
|
||||
|
||||
Revision ID: aa4689f80796
|
||||
Revises: 21a19f0675f9
|
||||
Create Date: 2025-07-06 10:54:19.714809
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "aa4689f80796"
|
||||
down_revision: Union[str, None] = "21a19f0675f9"
|
||||
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",
|
||||
"refresh_token",
|
||||
existing_type=sa.VARCHAR(length=1024),
|
||||
type_=sa.String(length=4096),
|
||||
existing_nullable=True,
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column(
|
||||
"oauth_account",
|
||||
"refresh_token",
|
||||
existing_type=sa.String(length=4096),
|
||||
type_=sa.VARCHAR(length=1024),
|
||||
existing_nullable=True,
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,4 +1,5 @@
|
||||
from collections.abc import AsyncGenerator
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import Depends
|
||||
from fastapi_users.db import (
|
||||
@@ -6,14 +7,19 @@ 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)
|
||||
refresh_token: Mapped[Optional[str]] = mapped_column(
|
||||
String(length=4096), nullable=True
|
||||
)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user