"""adjusts avy_problem

Revision ID: 3f3683002faa
Revises: cac7975449dd
Create Date: 2021-01-18 14:07:37.428563

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from sqlalchemy.dialects.postgresql import JSONB

# revision identifiers, used by Alembic.
revision = '3f3683002faa'
down_revision = 'cac7975449dd'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('friends', 'request_status')
    op.add_column('plans', sa.Column('danger_rating', postgresql.JSONB(astext_type=sa.Text())))
    op.drop_constraint('plans_route_id_fkey', 'plans', type_='foreignkey')
    op.create_foreign_key(None, 'plans', 'routes', ['route_id'], ['id'])
    op.drop_constraint('problems_problem_type_id_fkey', 'problems', type_='foreignkey')
    op.create_foreign_key(None, 'problems', 'problem_types', ['problem_type_id'], ['id'])
    op.drop_column('problems', 'danger_rating')
    # op.drop_column('problems', 'elevation')
    # op.drop_column('problems', 'aspect')
    op.drop_constraint('routes_user_id_fkey', 'routes', type_='foreignkey')
    op.create_foreign_key(None, 'routes', 'users', ['user_id'], ['id'])
    # op.drop_constraint('user_plans_user_id_fkey', 'user_plans', type_='foreignkey')
    # op.drop_constraint('user_plans_plan_id_fkey', 'user_plans', type_='foreignkey')
    # op.create_foreign_key(None, 'user_plans', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    # op.create_foreign_key(None, 'user_plans', 'plans', ['plan_id'], ['id'], ondelete='CASCADE')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    # op.drop_constraint(None, 'user_plans', type_='foreignkey')
    # op.drop_constraint(None, 'user_plans', type_='foreignkey')
    # op.create_foreign_key('user_plans_plan_id_fkey', 'user_plans', 'plans', ['plan_id'], ['id'])
    # op.create_foreign_key('user_plans_user_id_fkey', 'user_plans', 'users', ['user_id'], ['id'])
    # op.drop_constraint(None, 'routes', type_='foreignkey')
    # op.create_foreign_key('routes_user_id_fkey', 'routes', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    # op.add_column('problems', sa.Column('aspect', sa.VARCHAR(length=50), autoincrement=False, nullable=False))
    # op.add_column('problems', sa.Column('elevation', sa.VARCHAR(length=150), autoincrement=False, nullable=True))
    # op.add_column('problems', sa.Column('danger_rating', sa.VARCHAR(length=50), autoincrement=False, nullable=False))
    # op.drop_constraint(None, 'problems', type_='foreignkey')
    # op.create_foreign_key('problems_problem_type_id_fkey', 'problems', 'problem_types', ['problem_type_id'], ['id'], ondelete='CASCADE')
    op.drop_column('problems', 'aspect_elevation')
    # op.drop_constraint(None, 'plans', type_='foreignkey')
    # op.create_foreign_key('plans_route_id_fkey', 'plans', 'routes', ['route_id'], ['id'], ondelete='CASCADE')
    op.drop_column('plans', 'danger_rating')
    op.add_column('friends', sa.Column('request_status', sa.BOOLEAN(), autoincrement=False, nullable=True))
    # ### end Alembic commands ###
