"""Extends the UUID-Field to 36 Characters

Revision ID: cab8c02211c6
Revises: 38eb5f63a8a4
Create Date: 2016-04-22 14:30:01.837297

"""

# revision identifiers, used by Alembic.
revision = 'cab8c02211c6'
down_revision = '38eb5f63a8a4'

from alembic import op
import sqlalchemy as sa


UPGRADE = """"""
DOWNGRADE = """"""


def iter_statements(stmts):
    for st in [x for x in stmts.split('\n') if x]:
        op.execute(st)


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('actions', 'uuid',
               existing_type=sa.CHAR(length=32),
               type_=sa.CHAR(length=36),
               existing_nullable=True)
    op.alter_column('forms', 'uuid',
               existing_type=sa.CHAR(length=32),
               type_=sa.CHAR(length=36),
               existing_nullable=True)
    op.alter_column('modules', 'uuid',
               existing_type=sa.CHAR(length=32),
               type_=sa.CHAR(length=36),
               existing_nullable=True)
    op.alter_column('profiles', 'uuid',
               existing_type=sa.CHAR(length=32),
               type_=sa.CHAR(length=36),
               existing_nullable=True)
    op.alter_column('roles', 'uuid',
               existing_type=sa.CHAR(length=32),
               type_=sa.CHAR(length=36),
               existing_nullable=True)
    op.alter_column('usergroups', 'uuid',
               existing_type=sa.CHAR(length=32),
               type_=sa.CHAR(length=36),
               existing_nullable=True)
    op.alter_column('users', 'uuid',
               existing_type=sa.CHAR(length=32),
               type_=sa.CHAR(length=36),
               existing_nullable=True)
    ### end Alembic commands ###
    iter_statements(UPGRADE)


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('users', 'uuid',
               existing_type=sa.CHAR(length=36),
               type_=sa.CHAR(length=32),
               existing_nullable=True)
    op.alter_column('usergroups', 'uuid',
               existing_type=sa.CHAR(length=36),
               type_=sa.CHAR(length=32),
               existing_nullable=True)
    op.alter_column('roles', 'uuid',
               existing_type=sa.CHAR(length=36),
               type_=sa.CHAR(length=32),
               existing_nullable=True)
    op.alter_column('profiles', 'uuid',
               existing_type=sa.CHAR(length=36),
               type_=sa.CHAR(length=32),
               existing_nullable=True)
    op.alter_column('modules', 'uuid',
               existing_type=sa.CHAR(length=36),
               type_=sa.CHAR(length=32),
               existing_nullable=True)
    op.alter_column('forms', 'uuid',
               existing_type=sa.CHAR(length=36),
               type_=sa.CHAR(length=32),
               existing_nullable=True)
    op.alter_column('actions', 'uuid',
               existing_type=sa.CHAR(length=36),
               type_=sa.CHAR(length=32),
               existing_nullable=True)
    ### end Alembic commands ###
    iter_statements(DOWNGRADE)
