"""polls Revision ID: 05e3a7023a1e Revises: 9752fb47d7a6 Create Date: 2024-05-16 20:47:35.566151 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = '05e3a7023a1e' down_revision = '9752fb47d7a6' branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('poll', sa.Column('post_id', sa.Integer(), nullable=False), sa.Column('end_poll', sa.DateTime(), nullable=True), sa.Column('mode', sa.String(length=10), nullable=True), sa.Column('local_only', sa.Boolean(), nullable=True), sa.Column('latest_vote', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['post_id'], ['post.id'], ), sa.PrimaryKeyConstraint('post_id') ) op.create_table('poll_choice', sa.Column('id', sa.Integer(), nullable=False), sa.Column('post_id', sa.Integer(), nullable=True), sa.Column('choice_text', sa.String(length=200), nullable=True), sa.Column('sort_order', sa.Integer(), nullable=True), sa.Column('num_votes', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['post_id'], ['post.id'], ), sa.PrimaryKeyConstraint('id') ) with op.batch_alter_table('poll_choice', schema=None) as batch_op: batch_op.create_index(batch_op.f('ix_poll_choice_post_id'), ['post_id'], unique=False) op.create_table('poll_choice_vote', sa.Column('choice_id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('post_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['choice_id'], ['poll_choice.id'], ), sa.ForeignKeyConstraint(['post_id'], ['post.id'], ), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('choice_id', 'user_id') ) with op.batch_alter_table('poll_choice_vote', schema=None) as batch_op: batch_op.create_index(batch_op.f('ix_poll_choice_vote_post_id'), ['post_id'], unique=False) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('poll_choice_vote', schema=None) as batch_op: batch_op.drop_index(batch_op.f('ix_poll_choice_vote_post_id')) op.drop_table('poll_choice_vote') with op.batch_alter_table('poll_choice', schema=None) as batch_op: batch_op.drop_index(batch_op.f('ix_poll_choice_post_id')) op.drop_table('poll_choice') op.drop_table('poll') # ### end Alembic commands ###