mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:43:28 +02:00
add alembic migration for new usenet specific columns
This commit is contained in:
@@ -30,7 +30,6 @@ 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.usenet.models import UsenetDownload # noqa: E402
|
||||
|
||||
from media_manager.database import Base # noqa: E402
|
||||
|
||||
@@ -52,7 +51,6 @@ target_metadata = Base.metadata
|
||||
MovieFile,
|
||||
MovieRequest,
|
||||
Notification,
|
||||
UsenetDownload,
|
||||
)
|
||||
|
||||
|
||||
|
||||
95
alembic/versions/333866afcd2c_add_usenet_columns.py
Normal file
95
alembic/versions/333866afcd2c_add_usenet_columns.py
Normal file
@@ -0,0 +1,95 @@
|
||||
"""add-usenet-columns
|
||||
|
||||
Revision ID: 333866afcd2c
|
||||
Revises: aa4689f80796
|
||||
Create Date: 2025-07-09 20:55:42.338629
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "333866afcd2c"
|
||||
down_revision: Union[str, None] = "aa4689f80796"
|
||||
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.drop_table("usenet_download")
|
||||
op.add_column(
|
||||
"indexer_query_result",
|
||||
sa.Column(
|
||||
"usenet", sa.Boolean(), nullable=False, server_default=sa.text("false")
|
||||
),
|
||||
)
|
||||
op.add_column(
|
||||
"indexer_query_result",
|
||||
sa.Column("age", sa.Integer(), nullable=False, server_default=sa.text("0")),
|
||||
)
|
||||
op.add_column(
|
||||
"torrent",
|
||||
sa.Column(
|
||||
"usenet", sa.Boolean(), nullable=False, server_default=sa.text("false")
|
||||
),
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column("torrent", "usenet")
|
||||
op.drop_column("indexer_query_result", "age")
|
||||
op.drop_column("indexer_query_result", "usenet")
|
||||
op.create_table(
|
||||
"usenet_download",
|
||||
sa.Column("id", sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column(
|
||||
"status",
|
||||
postgresql.ENUM(
|
||||
"queued",
|
||||
"downloading",
|
||||
"completed",
|
||||
"failed",
|
||||
"paused",
|
||||
"extracting",
|
||||
"verifying",
|
||||
"repairing",
|
||||
"unknown",
|
||||
name="usenetdownloadstatus",
|
||||
),
|
||||
autoincrement=False,
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("title", sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column(
|
||||
"quality",
|
||||
postgresql.ENUM("uhd", "fullhd", "hd", "sd", "unknown", name="quality"),
|
||||
autoincrement=False,
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("imported", sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column("nzb_id", sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column("category", sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column(
|
||||
"size_mb",
|
||||
sa.DOUBLE_PRECISION(precision=53),
|
||||
autoincrement=False,
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column(
|
||||
"progress_percent",
|
||||
sa.DOUBLE_PRECISION(precision=53),
|
||||
autoincrement=False,
|
||||
nullable=False,
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("usenet_download_pkey")),
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user