"""fixed location table relationship with posts

Revision ID: 3b2dc6be6f2f
Revises: 3a8e8e2b715a
Create Date: 2020-11-11 15:31:18.604614

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '3b2dc6be6f2f'
down_revision = '3a8e8e2b715a'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('locations_post_id_fkey', 'locations', type_='foreignkey')
    op.drop_column('locations', 'post_id')
    op.add_column('posts', sa.Column('location_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'posts', 'locations', ['location_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'posts', type_='foreignkey')
    op.drop_column('posts', 'location_id')
    op.add_column('locations', sa.Column('post_id', sa.INTEGER(), autoincrement=False, nullable=False))
    op.create_foreign_key('locations_post_id_fkey', 'locations', 'posts', ['post_id'], ['id'])
    # ### end Alembic commands ###
