3845dc998475_menu_table_add.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. """menu table add
  2. Revision ID: 3845dc998475
  3. Revises: abc6bb9129ed
  4. Create Date: 2024-12-10 14:22:03.798597
  5. """
  6. from typing import Sequence, Union
  7. from alembic import op
  8. import sqlalchemy as sa
  9. from sqlalchemy.dialects import mysql
  10. # revision identifiers, used by Alembic.
  11. revision: str = '3845dc998475'
  12. down_revision: Union[str, None] = 'abc6bb9129ed'
  13. branch_labels: Union[str, Sequence[str], None] = None
  14. depends_on: Union[str, Sequence[str], None] = None
  15. def upgrade() -> None:
  16. # ### commands auto generated by Alembic - please adjust! ###
  17. op.create_table('menu_capacity',
  18. sa.Column('id', sa.Integer(), nullable=False),
  19. sa.Column('menu_id', sa.Integer(), nullable=True),
  20. sa.Column('capacity_id', sa.String(length=36), nullable=True),
  21. sa.Column('capacity_type', sa.Integer(), nullable=True),
  22. sa.PrimaryKeyConstraint('id'),
  23. sa.UniqueConstraint('menu_id', 'capacity_id', name='menu_capacity_id_ix')
  24. )
  25. op.create_index(op.f('ix_menu_capacity_id'), 'menu_capacity', ['id'], unique=False)
  26. op.create_table('web_menu',
  27. sa.Column('id', sa.Integer(), nullable=False),
  28. sa.Column('title', sa.String(length=128), nullable=True),
  29. sa.Column('dialog', sa.String(length=1000), nullable=True),
  30. sa.Column('desc', sa.String(length=1000), nullable=True),
  31. sa.Column('icon', sa.String(length=16), nullable=True),
  32. sa.Column('img', sa.String(length=255), nullable=True),
  33. sa.PrimaryKeyConstraint('id')
  34. )
  35. op.create_index(op.f('ix_web_menu_id'), 'web_menu', ['id'], unique=False)
  36. op.drop_column('knowledgebase', 'count')
  37. # ### end Alembic commands ###
  38. def downgrade() -> None:
  39. # ### commands auto generated by Alembic - please adjust! ###
  40. op.add_column('knowledgebase', sa.Column('count', mysql.VARCHAR(length=32), nullable=True))
  41. op.drop_index(op.f('ix_web_menu_id'), table_name='web_menu')
  42. op.drop_table('web_menu')
  43. op.drop_index(op.f('ix_menu_capacity_id'), table_name='menu_capacity')
  44. op.drop_table('menu_capacity')
  45. # ### end Alembic commands ###