"""create todo table Revision ID: 0001 Revises: Create Date: 2023-10-30 """ import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision = '0001' down_revision = None branch_labels = None depends_on = None def upgrade() -> None: # Create enum type for todo priority priority_enum = sa.Enum('low', 'medium', 'high', name='todopriority') priority_enum.create(op.get_bind(), checkfirst=True) # Create todos table op.create_table( 'todo', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(length=255), nullable=False), sa.Column('description', sa.String(length=1000), nullable=True), sa.Column('priority', priority_enum, nullable=False, default='medium'), sa.Column('completed', sa.Boolean(), nullable=False, default=False), sa.Column('created_at', sa.DateTime(), nullable=False, server_default=sa.func.now()), sa.Column('updated_at', sa.DateTime(), nullable=False, server_default=sa.func.now(), onupdate=sa.func.now()), sa.PrimaryKeyConstraint('id') ) # Create indexes op.create_index(op.f('ix_todo_id'), 'todo', ['id'], unique=False) op.create_index(op.f('ix_todo_title'), 'todo', ['title'], unique=False) def downgrade() -> None: # Drop indexes op.drop_index(op.f('ix_todo_title'), table_name='todo') op.drop_index(op.f('ix_todo_id'), table_name='todo') # Drop table op.drop_table('todo') # Drop enum type sa.Enum(name='todopriority').drop(op.get_bind(), checkfirst=True)