learnhouse/apps/api/migrations/versions/9e031a0358d1_video_thumbnails.py

41 lines
1.3 KiB
Python

"""Video Thumbnails
Revision ID: 9e031a0358d1
Revises: eb10d15465b3
Create Date: 2025-06-20 21:28:50.735540
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa # noqa: F401
import sqlmodel # noqa: F401
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = '9e031a0358d1'
down_revision: Union[str, None] = 'eb10d15465b3'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# Create the ENUM type first
thumbnail_type_enum = postgresql.ENUM('IMAGE', 'VIDEO', 'BOTH', name='thumbnail_type')
thumbnail_type_enum.create(op.get_bind())
op.add_column('course', sa.Column('thumbnail_type', thumbnail_type_enum, nullable=True))
op.add_column('course', sa.Column('thumbnail_video', sa.String(), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('course', 'thumbnail_video')
op.drop_column('course', 'thumbnail_type')
# Drop the ENUM type
thumbnail_type_enum = postgresql.ENUM('IMAGE', 'VIDEO', 'BOTH', name='thumbnail_type')
thumbnail_type_enum.drop(op.get_bind())
# ### end Alembic commands ###