"""init

Revision ID: 221c0780b151
Revises: 
Create Date: 2020-08-05 18:01:52.814987

"""
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils


# revision identifiers, used by Alembic.
revision = '221c0780b151'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('point_of_interest',
    sa.Column('id', sa.DECIMAL(precision=22, scale=0), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('location', sa.ARRAY(sa.DECIMAL()), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('route',
    sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('origin', sa.ARRAY(sa.DECIMAL()), nullable=False),
    sa.Column('destination', sa.ARRAY(sa.DECIMAL()), nullable=False),
    sa.Column('waypoints', sa.JSON(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('service_area',
    sa.Column('id', sa.DECIMAL(precision=22, scale=0), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('area_type', sa.Enum('INVALID_TYPE', 'P2P', 'RESTRICTED', 'PICKUPS_EXCLUDED', 'OUT_OF_ODD', name='areatype'), nullable=True),
    sa.Column('polygon', sa.JSON(), nullable=False),
    sa.Column('release_status', sa.Enum('ALPHA', 'BETA', 'RELEASE', 'P2P', name='releasestatus'), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('service_area_to_poi',
    sa.Column('service_area_id', sa.DECIMAL(precision=22, scale=0), nullable=True),
    sa.Column('poi_id', sa.DECIMAL(precision=22, scale=0), nullable=True),
    sa.ForeignKeyConstraint(['poi_id'], ['point_of_interest.id'], ),
    sa.ForeignKeyConstraint(['service_area_id'], ['service_area.id'], )
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('service_area_to_poi')
    op.drop_table('service_area')
    op.drop_table('route')
    op.drop_table('point_of_interest')
    # ### end Alembic commands ###
