mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: create ENUM type for thumbnail_type and update course migration
This commit is contained in:
parent
2966ac91b7
commit
63cb3bfd59
1 changed files with 10 additions and 2 deletions
|
|
@ -21,8 +21,12 @@ depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### 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))
|
# Create the ENUM type first
|
||||||
op.add_column('course', sa.Column('thumbnail_video', sqlmodel.sql.sqltypes.AutoString(), nullable=True))
|
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 ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,4 +34,8 @@ def downgrade() -> None:
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.drop_column('course', 'thumbnail_video')
|
op.drop_column('course', 'thumbnail_video')
|
||||||
op.drop_column('course', 'thumbnail_type')
|
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 ###
|
# ### end Alembic commands ###
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue