"""drops external_token table and creates table access_token

Revision ID: 5b7add77d694
Revises: 06bf1080e004
Create Date: 2018-11-26 09:07:31.555275
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '5b7add77d694'
down_revision = '06bf1080e004'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('access_token',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('provider', sa.String(length=36), nullable=False),
    sa.Column('code', sa.String(length=50), nullable=True),
    sa.Column('access_token', sa.String(length=400), nullable=False),
    sa.Column('refresh_token', sa.String(length=400), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_table('external_token')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('external_token',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('provider', sa.VARCHAR(length=36), autoincrement=False, nullable=False),
    sa.Column('code', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
    sa.Column('access_token', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='external_token_user_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='external_token_pkey')
    )
    op.drop_table('access_token')
    # ### end Alembic commands ###
