"""'resume-restructure'

Revision ID: 9086ddbe886a
Revises: 324f0807d662
Create Date: 2018-04-17 14:01:20.888963

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9086ddbe886a'
down_revision = '324f0807d662'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('award',
    sa.Column('award_id', sa.Integer(), nullable=False),
    sa.Column('award_name', sa.String(length=100), nullable=True),
    sa.Column('award_date', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('award_id')
    )
    op.create_table('experience',
    sa.Column('experience_id', sa.Integer(), nullable=False),
    sa.Column('location', sa.String(length=100), nullable=True),
    sa.Column('title', sa.String(length=100), nullable=True),
    sa.Column('start_date', sa.DateTime(), nullable=True),
    sa.Column('end_date', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('experience_id')
    )
    op.create_table('reference',
    sa.Column('reference_id', sa.Integer(), nullable=False),
    sa.Column('reference_name', sa.String(length=100), nullable=True),
    sa.Column('title', sa.String(length=50), nullable=True),
    sa.Column('company', sa.String(length=100), nullable=True),
    sa.Column('phone', sa.Integer(), nullable=True),
    sa.Column('email', sa.String(length=100), nullable=True),
    sa.PrimaryKeyConstraint('reference_id')
    )
    op.create_table('resume',
    sa.Column('resume_id', sa.Integer(), nullable=False),
    sa.Column('pinned', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('resume_id')
    )
    op.create_table('awards',
    sa.Column('resume_id', sa.Integer(), nullable=False),
    sa.Column('award_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['award_id'], ['award.award_id'], ),
    sa.ForeignKeyConstraint(['resume_id'], ['resume.resume_id'], ),
    sa.PrimaryKeyConstraint('resume_id', 'award_id')
    )
    op.create_table('experiences',
    sa.Column('resume_id', sa.Integer(), nullable=False),
    sa.Column('experience_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['experience_id'], ['experience.experience_id'], ),
    sa.ForeignKeyConstraint(['resume_id'], ['resume.resume_id'], ),
    sa.PrimaryKeyConstraint('resume_id', 'experience_id')
    )
    op.create_table('references',
    sa.Column('resume_id', sa.Integer(), nullable=False),
    sa.Column('reference_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['reference_id'], ['reference.reference_id'], ),
    sa.ForeignKeyConstraint(['resume_id'], ['resume.resume_id'], ),
    sa.PrimaryKeyConstraint('resume_id', 'reference_id')
    )
    op.drop_index('ix_post_timestamp', table_name='post')
    op.drop_table('post')
    op.add_column('user', sa.Column('user_id', sa.Integer(), nullable=False))
    op.alter_column('user', 'username',
               existing_type=sa.VARCHAR(length=64),
               nullable=False)
    op.drop_column('user', 'id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('id', sa.INTEGER(), nullable=False))
    op.alter_column('user', 'username',
               existing_type=sa.VARCHAR(length=64),
               nullable=True)
    op.drop_column('user', 'user_id')
    op.create_table('post',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('body', sa.VARCHAR(length=140), nullable=True),
    sa.Column('timestamp', sa.DATETIME(), nullable=True),
    sa.Column('user_id', sa.INTEGER(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('ix_post_timestamp', 'post', ['timestamp'], unique=False)
    op.drop_table('references')
    op.drop_table('experiences')
    op.drop_table('awards')
    op.drop_table('resume')
    op.drop_table('reference')
    op.drop_table('experience')
    op.drop_table('award')
    # ### end Alembic commands ###
