"""initial migration

Revision ID: 90da8dfef913
Revises: None
Create Date: 2016-11-03 20:28:45.147601

"""

# revision identifiers, used by Alembic.
revision = '90da8dfef913'
down_revision = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('_users_old_20161102')
    op.drop_table('_users_old_20161103')
    op.add_column('roles', sa.Column('default', sa.Boolean(), nullable=True))
    op.add_column('roles', sa.Column('permissions', sa.Integer(), nullable=True))
    op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False)
    op.create_unique_constraint(None, 'roles', ['name'])
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_users_email'), table_name='users')
    op.drop_constraint(None, 'roles', type_='unique')
    op.drop_index(op.f('ix_roles_default'), table_name='roles')
    op.drop_column('roles', 'permissions')
    op.drop_column('roles', 'default')
    op.create_table('_users_old_20161103',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('email', sa.TEXT(length=64, collation=0), nullable=True),
    sa.Column('username', sa.VARCHAR(length=64, collation=0), nullable=True),
    sa.Column('role_id', sa.INTEGER(), nullable=True),
    sa.Column('password_hash', sa.TEXT(length=128, collation=0), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('_users_old_20161102',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('username', sa.VARCHAR(length=64, collation=0), nullable=True),
    sa.Column('role_id', sa.INTEGER(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###
