"""this migration updates the comments model

Revision ID: e7a0527904b8
Revises: 3daa517490e3
Create Date: 2018-05-27 23:39:57.684511

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'e7a0527904b8'
down_revision = '3daa517490e3'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('comments', sa.Column('author_id', sa.Integer(), nullable=True))
    op.add_column('comments', sa.Column('timestamp', sa.DateTime(), nullable=True))
    op.create_index(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False)
    op.drop_constraint('comments_user_id_fkey', 'comments', type_='foreignkey')
    op.create_foreign_key(None, 'comments', 'users', ['author_id'], ['id'])
    op.drop_column('comments', 'user_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('comments', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'comments', type_='foreignkey')
    op.create_foreign_key('comments_user_id_fkey', 'comments', 'users', ['user_id'], ['id'])
    op.drop_index(op.f('ix_comments_timestamp'), table_name='comments')
    op.drop_column('comments', 'timestamp')
    op.drop_column('comments', 'author_id')
    # ### end Alembic commands ###
