"""added polymorphic relation between definition

Revision ID: 7719d1979813
Revises: d34395018755
Create Date: 2020-11-04 11:05:47.714325

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = '7719d1979813'
down_revision = 'd34395018755'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('definition',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=250), nullable=True),
    sa.Column('scope_id', sa.Integer(), nullable=True),
    sa.Column('lineno', sa.Integer(), nullable=True),
    sa.Column('colno', sa.Integer(), nullable=True),
    sa.Column('definition_type', sa.String(length=50), nullable=True),
    sa.Column('first_definition', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['scope_id'], ['scope.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_table('class')
    op.drop_table('variable')
    op.drop_table('function')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('function',
    sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
    sa.Column('name', mysql.VARCHAR(length=50), nullable=True),
    sa.Column('scope_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['scope_id'], ['scope.id'], name='function_ibfk_1'),
    sa.PrimaryKeyConstraint('id'),
    mysql_default_charset='utf8mb4',
    mysql_engine='InnoDB'
    )
    op.create_table('variable',
    sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
    sa.Column('name', mysql.VARCHAR(length=50), nullable=True),
    sa.Column('scope_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('colno', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('first_definition', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True),
    sa.Column('lineno', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.CheckConstraint('`first_definition` in (0,1)', name='CONSTRAINT_1'),
    sa.ForeignKeyConstraint(['scope_id'], ['scope.id'], name='variable_ibfk_1'),
    sa.PrimaryKeyConstraint('id'),
    mysql_default_charset='utf8mb4',
    mysql_engine='InnoDB'
    )
    op.create_table('class',
    sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
    sa.Column('name', mysql.VARCHAR(length=50), nullable=True),
    sa.Column('scope_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['scope_id'], ['scope.id'], name='class_ibfk_1'),
    sa.PrimaryKeyConstraint('id'),
    mysql_default_charset='utf8mb4',
    mysql_engine='InnoDB'
    )
    op.drop_table('definition')
    # ### end Alembic commands ###
