"""empty message

Revision ID: 22601d0ed435
Revises: 
Create Date: 2018-08-28 13:38:06.876122

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('educators',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=128), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('groups',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=128), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('lessons',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('name', sa.String(length=128), nullable=True),
    sa.Column('types', sa.JSON(), nullable=True),
    sa.Column('days', sa.JSON(), nullable=True),
    sa.Column('times', sa.JSON(), nullable=True),
    sa.Column('educators', sa.JSON(), nullable=True),
    sa.Column('locations', sa.JSON(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('tg_id', sa.Integer(), nullable=False),
    sa.Column('is_educator', sa.Boolean(), nullable=False),
    sa.Column('is_full_place', sa.Boolean(), nullable=False),
    sa.Column('is_subscribed', sa.Boolean(), nullable=False),
    sa.Column('home_station_code', sa.String(length=10), nullable=False),
    sa.Column('univer_station_code', sa.String(length=10), nullable=False),
    sa.Column('current_group_id', sa.Integer(), nullable=True),
    sa.Column('current_educator_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['current_educator_id'], ['educators.id'], ),
    sa.ForeignKeyConstraint(['current_group_id'], ['groups.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_tg_id'), 'users', ['tg_id'], unique=True)
    op.create_table('users_added_lesson',
    sa.Column('lesson', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['lesson'], ['lessons.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('lesson', 'user_id')
    )
    op.create_table('users_chosen_educators',
    sa.Column('lesson', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['lesson'], ['lessons.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('lesson', 'user_id')
    )
    op.create_table('users_educators',
    sa.Column('educator_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['educator_id'], ['educators.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('educator_id', 'user_id')
    )
    op.create_table('users_groups',
    sa.Column('group_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['group_id'], ['groups.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('group_id', 'user_id')
    )
    op.create_table('users_hidden_lessons',
    sa.Column('lesson', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['lesson'], ['lessons.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('lesson', 'user_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('users_hidden_lessons')
    op.drop_table('users_groups')
    op.drop_table('users_educators')
    op.drop_table('users_chosen_educators')
    op.drop_table('users_added_lesson')
    op.drop_index(op.f('ix_users_tg_id'), table_name='users')
    op.drop_table('users')
    op.drop_table('lessons')
    op.drop_table('groups')
    op.drop_table('educators')
    # ### end Alembic commands ###
