diff --git a/apps/api/migrations/versions/9e031a0358d1_video_thumbnails.py b/apps/api/migrations/versions/9e031a0358d1_video_thumbnails.py index 7bede50e..59d89b68 100644 --- a/apps/api/migrations/versions/9e031a0358d1_video_thumbnails.py +++ b/apps/api/migrations/versions/9e031a0358d1_video_thumbnails.py @@ -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 ###