"""empty message

Revision ID: 4a332e4536d2
Revises: 
Create Date: 2017-05-23 01:10:50.768687

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('acl__resources',
    sa.Column('_id', sa.Integer(), nullable=False),
    sa.Column('_created', sa.DateTime(), nullable=True),
    sa.Column('_updated', sa.DateTime(), nullable=True),
    sa.Column('_etag', sa.String(), nullable=True),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.PrimaryKeyConstraint('_id')
    )
    op.create_index(op.f('ix_acl__resources_name'), 'acl__resources', ['name'], unique=True)
    op.create_table('acl__roles',
    sa.Column('_id', sa.Integer(), nullable=False),
    sa.Column('_created', sa.DateTime(), nullable=True),
    sa.Column('_updated', sa.DateTime(), nullable=True),
    sa.Column('_etag', sa.String(), nullable=True),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.PrimaryKeyConstraint('_id')
    )
    op.create_index(op.f('ix_acl__roles_name'), 'acl__roles', ['name'], unique=True)
    op.create_table('oc__specialization',
    sa.Column('_id', sa.Integer(), nullable=False),
    sa.Column('_created', sa.DateTime(), nullable=True),
    sa.Column('_updated', sa.DateTime(), nullable=True),
    sa.Column('_etag', sa.String(), nullable=True),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.PrimaryKeyConstraint('_id')
    )
    op.create_index(op.f('ix_oc__specialization_name'), 'oc__specialization', ['name'], unique=True)
    op.create_table('users',
    sa.Column('_id', sa.Integer(), nullable=False),
    sa.Column('_created', sa.DateTime(), nullable=True),
    sa.Column('_updated', sa.DateTime(), nullable=True),
    sa.Column('_etag', sa.String(), nullable=True),
    sa.Column('email', sa.String(length=255), nullable=False),
    sa.Column('password', sa.String(length=255), nullable=False),
    sa.Column('firstname', sa.String(length=255), nullable=True),
    sa.Column('lastname', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('_id')
    )
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
    op.create_table('acl__permissions',
    sa.Column('_id', sa.Integer(), nullable=False),
    sa.Column('_created', sa.DateTime(), nullable=True),
    sa.Column('_updated', sa.DateTime(), nullable=True),
    sa.Column('_etag', sa.String(), nullable=True),
    sa.Column('resource_id', sa.Integer(), nullable=False),
    sa.Column('role_id', sa.Integer(), nullable=False),
    sa.Column('action', sa.String(length=32), nullable=False),
    sa.ForeignKeyConstraint(['resource_id'], ['acl__resources._id'], ),
    sa.ForeignKeyConstraint(['role_id'], ['acl__roles._id'], ),
    sa.PrimaryKeyConstraint('_id'),
    sa.UniqueConstraint('resource_id', 'role_id', 'action', name='_acl__permissions_uc')
    )
    op.create_index(op.f('ix_acl__permissions_action'), 'acl__permissions', ['action'], unique=False)
    op.create_table('acl__user_assignments',
    sa.Column('_id', sa.Integer(), nullable=False),
    sa.Column('_created', sa.DateTime(), nullable=True),
    sa.Column('_updated', sa.DateTime(), nullable=True),
    sa.Column('_etag', sa.String(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('role_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['role_id'], ['acl__roles._id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users._id'], ),
    sa.PrimaryKeyConstraint('_id'),
    sa.UniqueConstraint('user_id', 'role_id', name='_acl__user_assignments_uc')
    )
    op.create_table('oc__class',
    sa.Column('_id', sa.Integer(), nullable=False),
    sa.Column('_created', sa.DateTime(), nullable=True),
    sa.Column('_updated', sa.DateTime(), nullable=True),
    sa.Column('_etag', sa.String(), nullable=True),
    sa.Column('specialization_id', sa.Integer(), nullable=False),
    sa.Column('teacher_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['specialization_id'], ['oc__specialization._id'], ),
    sa.ForeignKeyConstraint(['teacher_id'], ['users._id'], ),
    sa.PrimaryKeyConstraint('_id')
    )
    op.create_table('oc__teacher_specialization',
    sa.Column('_id', sa.Integer(), nullable=False),
    sa.Column('_created', sa.DateTime(), nullable=True),
    sa.Column('_updated', sa.DateTime(), nullable=True),
    sa.Column('_etag', sa.String(), nullable=True),
    sa.Column('specialization_id', sa.Integer(), nullable=False),
    sa.Column('teacher_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['specialization_id'], ['oc__specialization._id'], ),
    sa.ForeignKeyConstraint(['teacher_id'], ['users._id'], ),
    sa.PrimaryKeyConstraint('_id')
    )
    op.create_table('oc__student_in_class',
    sa.Column('_id', sa.Integer(), nullable=False),
    sa.Column('_created', sa.DateTime(), nullable=True),
    sa.Column('_updated', sa.DateTime(), nullable=True),
    sa.Column('_etag', sa.String(), nullable=True),
    sa.Column('class_id', sa.Integer(), nullable=False),
    sa.Column('student_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['class_id'], ['oc__class._id'], ),
    sa.ForeignKeyConstraint(['student_id'], ['users._id'], ),
    sa.PrimaryKeyConstraint('_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('oc__student_in_class')
    op.drop_table('oc__teacher_specialization')
    op.drop_table('oc__class')
    op.drop_table('acl__user_assignments')
    op.drop_index(op.f('ix_acl__permissions_action'), table_name='acl__permissions')
    op.drop_table('acl__permissions')
    op.drop_index(op.f('ix_users_email'), table_name='users')
    op.drop_table('users')
    op.drop_index(op.f('ix_oc__specialization_name'), table_name='oc__specialization')
    op.drop_table('oc__specialization')
    op.drop_index(op.f('ix_acl__roles_name'), table_name='acl__roles')
    op.drop_table('acl__roles')
    op.drop_index(op.f('ix_acl__resources_name'), table_name='acl__resources')
    op.drop_table('acl__resources')
    # ### end Alembic commands ###
