"""empty message

Revision ID: d1e8bb87d422
Revises: 58c18ed26615
Create Date: 2019-10-17 09:48:21.019329

"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql
from stand.migration_utils import is_sqlite

# revision identifiers, used by Alembic.
revision = 'd1e8bb87d422'
down_revision = '58c18ed26615'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    if is_sqlite():
        with op.batch_alter_table('cluster') as batch_op:
            batch_op.add_column(sa.Column('auth_token', sa.String(length=1000), nullable=True))
        # Enum types are not supported in sqlite. Ignores changes.
    else:
        op.add_column('cluster', sa.Column('auth_token', sa.String(length=1000),
                                       nullable=True))
        op.alter_column('job_result', 'type',
                    existing_type=mysql.ENUM('VISUALIZATION', 'HTML', 'TEXT',
                                             'OTHER', 'MODEL', 'METRIC'),
                    nullable=False, server_default='TEXT')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    if not is_sqlite():
        op.alter_column('job_result', 'type',
                    existing_type=mysql.ENUM('VISUALIZATION', 'HTML', 'TEXT',
                                             'OTHER', 'MODEL', 'METRIC'),
                    nullable=True)
        op.drop_column('cluster', 'auth_token')
    else:
        with op.batch_alter_table('cluster') as batch_op:
            batch_op.drop_column('auth_token')
    # ### end Alembic commands ###
