"""Initial Migration

Revision ID: fb076abc360e
Revises: 128629fac885
Create Date: 2020-11-30 05:51:05.244762

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'fb076abc360e'
down_revision = '128629fac885'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('categories')
    op.add_column('comments', sa.Column('comment', sa.Text(), nullable=False))
    op.alter_column('comments', 'pitch_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('comments', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.drop_column('comments', 'Comment')
    op.alter_column('downvotes', 'pitch_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('downvotes', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.add_column('pitches', sa.Column('pitch', sa.Text(), nullable=False))
    op.add_column('pitches', sa.Column('time', sa.DateTime(), nullable=True))
    op.drop_column('pitches', 'post')
    op.drop_column('pitches', 'votes')
    op.alter_column('upvotes', 'pitch_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('upvotes', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_users_username'), table_name='users')
    op.alter_column('upvotes', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('upvotes', 'pitch_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.add_column('pitches', sa.Column('votes', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('pitches', sa.Column('post', sa.TEXT(), autoincrement=False, nullable=False))
    op.drop_column('pitches', 'time')
    op.drop_column('pitches', 'pitch')
    op.alter_column('downvotes', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('downvotes', 'pitch_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.add_column('comments', sa.Column('Comment', sa.TEXT(), autoincrement=False, nullable=True))
    op.alter_column('comments', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('comments', 'pitch_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.drop_column('comments', 'comment')
    op.create_table('categories',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('title', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('post', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='categories_user_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='categories_pkey')
    )
    # ### end Alembic commands ###
