feat: create ENUM type for thumbnail_type and update course migration

This commit is contained in:
swve 2025-06-20 22:55:47 +02:00
parent 2966ac91b7
commit 63cb3bfd59

View file

@ -21,8 +21,12 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('course', sa.Column('thumbnail_type', postgresql.ENUM('IMAGE', 'VIDEO', 'BOTH', name='thumbnailtype', create_type=False), nullable=True))
op.add_column('course', sa.Column('thumbnail_video', sqlmodel.sql.sqltypes.AutoString(), nullable=True))
# 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 ###
@ -30,4 +34,8 @@ 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 ###