"""empty message

Revision ID: 8a40248050c6
Revises:
Create Date: 2018-09-30 20:48:04.863807

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '8a40248050c6'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute("SET FOREIGN_KEY_CHECKS=0;")
    op.create_table('itinerary',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('storyline_id', sa.Integer(), nullable=True),
    sa.Column('planning_description', sa.Text(), nullable=True),
    sa.Column('actual_description', sa.Text(), nullable=True),
    sa.Column('day', sa.Date(), nullable=True),
    sa.Column('done', sa.Boolean(), nullable=True),
    sa.Column('planned_start_point', sa.String(length=132), nullable=True),
    sa.Column('planned_end_point', sa.String(length=132), nullable=True),
    sa.Column('planned_distance', sa.Integer(), nullable=True),
    sa.Column('planned_stay', sa.String(length=132), nullable=True),
    sa.Column('actual_start_point', sa.String(length=132), nullable=True),
    sa.Column('actual_end_point', sa.String(length=132), nullable=True),
    sa.Column('actual_distance', sa.Integer(), nullable=True),
    sa.Column('actual_stay', sa.String(length=132), nullable=True),
    sa.ForeignKeyConstraint(['storyline_id'], ['storyline.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_itinerary_day'), 'itinerary', ['day'], unique=False)
    op.create_table('media',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('type', sa.String(length=32), nullable=True),
    sa.Column('name', sa.String(length=140), nullable=True),
    sa.Column('filename', sa.String(length=140), nullable=True),
    sa.Column('url', sa.String(length=1400), nullable=True),
    sa.Column('story_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['story_id'], ['story.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_media_type'), 'media', ['type'], unique=False)
    op.create_table('story',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=140), nullable=True),
    sa.Column('content', sa.Text(), nullable=True),
    sa.Column('html_content', sa.Text(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('storyline_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['storyline_id'], ['storyline.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_story_timestamp'), 'story', ['timestamp'], unique=False)
    op.create_index(op.f('ix_story_title'), 'story', ['title'], unique=False)
    op.create_table('story_tags',
    sa.Column('story_id', sa.Integer(), nullable=True),
    sa.Column('tag_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['story_id'], ['story.id'], ),
    sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], )
    )
    op.create_table('storyline',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.Column('description', sa.String(length=140), nullable=True),
    sa.Column('administrator_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['administrator_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_storyline_name'), 'storyline', ['name'], unique=False)
    op.create_table('storyline_members',
    sa.Column('member_id', sa.Integer(), nullable=True),
    sa.Column('storyline_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['member_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['storyline_id'], ['storyline.id'], )
    )
    op.create_table('tag',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.Column('slug', sa.String(length=32), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_tag_name'), 'tag', ['name'], unique=False)
    op.create_index(op.f('ix_tag_slug'), 'tag', ['slug'], unique=False)
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=120), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('about_me', sa.String(length=140), nullable=True),
    sa.Column('last_seen', sa.DateTime(), nullable=True),
    sa.Column('current_line_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['current_line_id'], ['storyline.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    op.execute("SET FOREIGN_KEY_CHECKS=1;")
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_user_username'), table_name='user')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_table('user')
    op.drop_index(op.f('ix_tag_slug'), table_name='tag')
    op.drop_index(op.f('ix_tag_name'), table_name='tag')
    op.drop_table('tag')
    op.drop_table('storyline_members')
    op.drop_index(op.f('ix_storyline_name'), table_name='storyline')
    op.drop_table('storyline')
    op.drop_table('story_tags')
    op.drop_index(op.f('ix_story_title'), table_name='story')
    op.drop_index(op.f('ix_story_timestamp'), table_name='story')
    op.drop_table('story')
    op.drop_index(op.f('ix_media_type'), table_name='media')
    op.drop_table('media')
    op.drop_index(op.f('ix_itinerary_day'), table_name='itinerary')
    op.drop_table('itinerary')
    # ### end Alembic commands ###
