"""create key-value, callbacks and association tables

Revision ID: 015ccdff2ad0
Revises: 
Create Date: 2017-03-30 18:17:01.552087

"""

# revision identifiers, used by Alembic.
revision = '015ccdff2ad0'
down_revision = None
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('callback',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('callback', sa.String(length=200), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('key',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('key', sa.String(length=50), nullable=False),
    sa.Column('value', sa.String(length=50), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_key_key'), 'key', ['key'], unique=True)
    op.create_index(op.f('ix_key_value'), 'key', ['value'], unique=False)
    op.create_table('key_callback',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('key_id', sa.Integer(), nullable=False),
    sa.Column('callback_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['callback_id'], ['callback.id'], ),
    sa.ForeignKeyConstraint(['key_id'], ['key.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_key_callback_callback_id'), 'key_callback', ['callback_id'], unique=False)
    op.create_index(op.f('ix_key_callback_key_id'), 'key_callback', ['key_id'], unique=False)
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_key_callback_key_id'), table_name='key_callback')
    op.drop_index(op.f('ix_key_callback_callback_id'), table_name='key_callback')
    op.drop_table('key_callback')
    op.drop_index(op.f('ix_key_value'), table_name='key')
    op.drop_index(op.f('ix_key_key'), table_name='key')
    op.drop_table('key')
    op.drop_table('callback')
    ### end Alembic commands ###
