"""Added Post and linked to User

Revision ID: d73b40264cc7
Revises: d4867f3a4c0a
Create Date: 2020-06-18 20:13:20.034392

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'd73b40264cc7'
down_revision = 'd4867f3a4c0a'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('post',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('text', sa.String(), nullable=False),
    sa.Column('score', sa.Integer(), nullable=True),
    sa.Column('date', sa.DateTime(), nullable=True),
    sa.Column('country', sa.String(), nullable=True),
    sa.Column('sublocality', sa.String(), nullable=True),
    sa.Column('neighborhood', sa.String(), nullable=True),
    sa.Column('colloquial_area', sa.String(), nullable=True),
    sa.Column('administrative_area_level_3', sa.String(), nullable=True),
    sa.Column('administrative_area_level_1', sa.String(), nullable=True),
    sa.Column('administrative_area_level_2', sa.String(), nullable=True),
    sa.Column('administrative_area_level_5', sa.String(), nullable=True),
    sa.Column('locality', sa.String(), nullable=True),
    sa.Column('administrative_area_level_4', sa.String(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_post_administrative_area_level_1'), 'post', ['administrative_area_level_1'], unique=False)
    op.create_index(op.f('ix_post_administrative_area_level_2'), 'post', ['administrative_area_level_2'], unique=False)
    op.create_index(op.f('ix_post_administrative_area_level_3'), 'post', ['administrative_area_level_3'], unique=False)
    op.create_index(op.f('ix_post_administrative_area_level_4'), 'post', ['administrative_area_level_4'], unique=False)
    op.create_index(op.f('ix_post_administrative_area_level_5'), 'post', ['administrative_area_level_5'], unique=False)
    op.create_index(op.f('ix_post_colloquial_area'), 'post', ['colloquial_area'], unique=False)
    op.create_index(op.f('ix_post_country'), 'post', ['country'], unique=False)
    op.create_index(op.f('ix_post_date'), 'post', ['date'], unique=False)
    op.create_index(op.f('ix_post_id'), 'post', ['id'], unique=False)
    op.create_index(op.f('ix_post_locality'), 'post', ['locality'], unique=False)
    op.create_index(op.f('ix_post_neighborhood'), 'post', ['neighborhood'], unique=False)
    op.create_index(op.f('ix_post_sublocality'), 'post', ['sublocality'], unique=False)
    op.alter_column('user', 'email',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.alter_column('user', 'hashed_password',
               existing_type=sa.VARCHAR(),
               nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('user', 'hashed_password',
               existing_type=sa.VARCHAR(),
               nullable=True)
    op.alter_column('user', 'email',
               existing_type=sa.VARCHAR(),
               nullable=True)
    op.drop_index(op.f('ix_post_sublocality'), table_name='post')
    op.drop_index(op.f('ix_post_neighborhood'), table_name='post')
    op.drop_index(op.f('ix_post_locality'), table_name='post')
    op.drop_index(op.f('ix_post_id'), table_name='post')
    op.drop_index(op.f('ix_post_date'), table_name='post')
    op.drop_index(op.f('ix_post_country'), table_name='post')
    op.drop_index(op.f('ix_post_colloquial_area'), table_name='post')
    op.drop_index(op.f('ix_post_administrative_area_level_5'), table_name='post')
    op.drop_index(op.f('ix_post_administrative_area_level_4'), table_name='post')
    op.drop_index(op.f('ix_post_administrative_area_level_3'), table_name='post')
    op.drop_index(op.f('ix_post_administrative_area_level_2'), table_name='post')
    op.drop_index(op.f('ix_post_administrative_area_level_1'), table_name='post')
    op.drop_table('post')
    # ### end Alembic commands ###
