"""voting

Revision ID: 6b84580a94cd
Revises: f032dbdfbd1d
Create Date: 2023-09-10 19:59:15.735823

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '6b84580a94cd'
down_revision = 'f032dbdfbd1d'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('post_vote',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.Column('effect', sa.Float(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['post_id'], ['post.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('post_reply_vote',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('post_reply_id', sa.Integer(), nullable=True),
    sa.Column('effect', sa.Float(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['post_reply_id'], ['post_reply.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('activity_pub_log', schema=None) as batch_op:
        batch_op.add_column(sa.Column('activity_id', sa.String(length=100), nullable=True))
        batch_op.create_index(batch_op.f('ix_activity_pub_log_activity_id'), ['activity_id'], unique=False)

    with op.batch_alter_table('instance', schema=None) as batch_op:
        batch_op.add_column(sa.Column('vote_weight', sa.Float(), nullable=True))

    with op.batch_alter_table('user', schema=None) as batch_op:
        batch_op.add_column(sa.Column('reputation', sa.Float(), nullable=True))

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('user', schema=None) as batch_op:
        batch_op.drop_column('reputation')

    with op.batch_alter_table('instance', schema=None) as batch_op:
        batch_op.drop_column('vote_weight')

    with op.batch_alter_table('activity_pub_log', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_activity_pub_log_activity_id'))
        batch_op.drop_column('activity_id')

    op.drop_table('post_reply_vote')
    op.drop_table('post_vote')
    # ### end Alembic commands ###