"""user role addition for flask-security

Revision ID: 7d236df56164
Revises: 565fe598f344
Create Date: 2019-12-09 14:53:28.154815

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '7d236df56164'
down_revision = '565fe598f344'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('role',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('roles_users',
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
    )
    op.drop_index('ix_budget_category_category_title', table_name='budget_category')
    op.create_index(op.f('ix_budget_category_category_title'), 'budget_category', ['category_title'], unique=True)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_budget_category_category_title'), table_name='budget_category')
    op.create_index('ix_budget_category_category_title', 'budget_category', ['category_title'], unique=False)
    op.drop_table('roles_users')
    op.drop_table('role')
    # ### end Alembic commands ###
