"""empty message

Revision ID: c6b52d505963
Revises: 
Create Date: 2020-11-01 04:42:43.248723

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('master_keys',
    sa.Column('token', sa.String(length=120), nullable=False),
    sa.PrimaryKeyConstraint('token')
    )
    op.create_table('services',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=True),
    sa.Column('base_url', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=256), nullable=True),
    sa.Column('internal', sa.Boolean(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_services_base_url'), 'services', ['base_url'], unique=True)
    op.create_index(op.f('ix_services_name'), 'services', ['name'], unique=True)
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=32), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('company', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=32), nullable=True),
    sa.Column('access_token', sa.String(length=128), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_access_token'), 'users', ['access_token'], unique=True)
    op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
    op.create_table('access_table',
    sa.Column('access_token', sa.String(), nullable=True),
    sa.Column('service_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['access_token'], ['users.access_token'], ),
    sa.ForeignKeyConstraint(['service_id'], ['services.id'], )
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('access_table')
    op.drop_index(op.f('ix_users_username'), table_name='users')
    op.drop_index(op.f('ix_users_access_token'), table_name='users')
    op.drop_table('users')
    op.drop_index(op.f('ix_services_name'), table_name='services')
    op.drop_index(op.f('ix_services_base_url'), table_name='services')
    op.drop_table('services')
    op.drop_table('master_keys')
    # ### end Alembic commands ###
