"""add weather and boost info to sightings

Revision ID: c5e649196f94
Revises: 905cf0f89f5c
Create Date: 2017-12-20 00:24:14.874200

"""
from alembic import op
import sqlalchemy as sa
import sys
from pathlib import Path
monocle_dir = str(Path(__file__).resolve().parents[2])
if monocle_dir not in sys.path:
    sys.path.append(monocle_dir)
from monocle import db as db

# revision identifiers, used by Alembic.
revision = 'c5e649196f94'
down_revision = '905cf0f89f5c'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('sightings', sa.Column('weather_boosted_condition', sa.SmallInteger, nullable=True))
    op.add_column('sightings', sa.Column('weather_cell_id', sa.BigInteger, nullable=True))
    op.add_column('mystery_sightings', sa.Column('weather_boosted_condition', sa.SmallInteger, nullable=True))
    op.add_column('mystery_sightings', sa.Column('weather_cell_id', sa.BigInteger, nullable=True))
    op.create_index('ix_s2_cell_id', 'weather', ['s2_cell_id'], unique=True)
    op.create_index('ix_sightings_weather_cell', 'sightings', ['weather_cell_id'], unique=False)
    op.create_index('ix_mystery_weather_cell', 'mystery_sightings', ['weather_cell_id'], unique=False)
    op.create_foreign_key('sightings_fk_cellid', 'sightings', 'weather', ['weather_cell_id'], ['s2_cell_id'])
    op.create_foreign_key('mystery_sightings_fk_cellid', 'mystery_sightings', 'weather', ['weather_cell_id'], ['s2_cell_id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('mystery_sightings_fk_cellid', 'mystery_sightings', type_='foreignkey')
    op.drop_constraint('sightings_fk_cellid', 'sightings', type_='foreignkey')
    op.drop_index('ix_sightings_weather_cell', table_name='sightings')
    op.drop_index('ix_mystery_weather_cell', table_name='mystery_sightings')
    op.drop_index('ix_s2_cell_id', table_name='weather')
    op.drop_column('mystery_sightings', 'weather_cell_id')
    op.drop_column('mystery_sightings', 'weather_boosted_condition')
    op.drop_column('sightings', 'weather_cell_id')
    op.drop_column('sightings', 'weather_boosted_condition')
    # ### end Alembic commands ###
