"""empty message

Revision ID: 4c3eea649e45
Revises: 595333e172df
Create Date: 2019-05-06 17:40:20.377647

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '4c3eea649e45'
down_revision = '595333e172df'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('container_port_map',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('container_id', sa.Integer(), nullable=True),
    sa.Column('ipv4_address', sa.String(length=128), nullable=True),
    sa.Column('ipv6_address', sa.String(length=128), nullable=True),
    sa.Column('transport_protocol', sa.Enum('tcp', 'udp', name='transportprotocol'), nullable=True),
    sa.Column('port', sa.Integer(), nullable=True),
    sa.Column('app_protocol', sa.Enum('ssh', 'http', 'https', name='appprotocol'), nullable=True),
    sa.Column('app_name', sa.Enum('demoapp1', name='appname'), nullable=True),
    sa.Column('note', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['container_id'], ['container.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_constraint('container_ssh_key_id_fkey', 'container', type_='foreignkey')
    op.drop_column('container', 'ssh_key_id')
    op.add_column('ssh_key', sa.Column('add_to_authorized_keys', sa.Boolean(), nullable=True))
    op.add_column('ssh_key', sa.Column('key_cipher', sa.String(length=32), nullable=True))
    op.add_column('ssh_key', sa.Column('key_format', sa.String(length=32), nullable=True))
    op.add_column('ssh_key', sa.Column('private_key', sa.String(length=128), nullable=True))
    op.add_column('ssh_key', sa.Column('public_key', sa.String(length=128), nullable=True))
    op.drop_column('ssh_key', 'private')
    op.drop_column('ssh_key', 'public')
    op.drop_column('ssh_key', 'type')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('ssh_key', sa.Column('type', sa.VARCHAR(length=24), autoincrement=False, nullable=True))
    op.add_column('ssh_key', sa.Column('public', sa.VARCHAR(length=128), autoincrement=False, nullable=True))
    op.add_column('ssh_key', sa.Column('private', sa.VARCHAR(length=128), autoincrement=False, nullable=True))
    op.drop_column('ssh_key', 'public_key')
    op.drop_column('ssh_key', 'private_key')
    op.drop_column('ssh_key', 'key_format')
    op.drop_column('ssh_key', 'key_cipher')
    op.drop_column('ssh_key', 'add_to_authorized_keys')
    op.add_column('container', sa.Column('ssh_key_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('container_ssh_key_id_fkey', 'container', 'ssh_key', ['ssh_key_id'], ['id'])
    op.drop_table('container_port_map')
    # ### end Alembic commands ###
