"""init models

Revision ID: 40e3b8c47e29
Revises: 
Create Date: 2018-05-20 12:12:31.992087

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '40e3b8c47e29'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=120), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('added', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_added'), 'user', ['added'], unique=False)
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    op.create_table('organization',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('creator_id', sa.Integer(), nullable=True),
    sa.Column('orgname', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.Column('added', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['creator_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_organization_added'), 'organization', ['added'], unique=False)
    op.create_index(op.f('ix_organization_orgname'), 'organization', ['orgname'], unique=True)
    op.create_table('host',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('creator_id', sa.Integer(), nullable=True),
    sa.Column('org_id', sa.Integer(), nullable=True),
    sa.Column('host', sa.String(length=64), nullable=True),
    sa.Column('address', sa.String(length=120), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.Column('sysuser', sa.String(length=64), nullable=True),
    sa.Column('port', sa.Integer(), nullable=True),
    sa.Column('added', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['creator_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['org_id'], ['organization.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_host_added'), 'host', ['added'], unique=False)
    op.create_index(op.f('ix_host_address'), 'host', ['address'], unique=True)
    op.create_index(op.f('ix_host_host'), 'host', ['host'], unique=True)
    op.create_table('host_local_forward',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('host_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.Column('local_port', sa.Integer(), nullable=True),
    sa.Column('remote_port', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['host_id'], ['host.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_host_local_forward_local_port'), 'host_local_forward', ['local_port'], unique=True)
    op.create_index(op.f('ix_host_local_forward_name'), 'host_local_forward', ['name'], unique=True)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_host_local_forward_name'), table_name='host_local_forward')
    op.drop_index(op.f('ix_host_local_forward_local_port'), table_name='host_local_forward')
    op.drop_table('host_local_forward')
    op.drop_index(op.f('ix_host_host'), table_name='host')
    op.drop_index(op.f('ix_host_address'), table_name='host')
    op.drop_index(op.f('ix_host_added'), table_name='host')
    op.drop_table('host')
    op.drop_index(op.f('ix_organization_orgname'), table_name='organization')
    op.drop_index(op.f('ix_organization_added'), table_name='organization')
    op.drop_table('organization')
    op.drop_index(op.f('ix_user_username'), table_name='user')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_index(op.f('ix_user_added'), table_name='user')
    op.drop_table('user')
    # ### end Alembic commands ###
