"""empty message

Revision ID: 1e4edfefbb70
Revises: 
Create Date: 2020-11-12 21:38:40.495161

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

# revision identifiers, used by Alembic.
revision = '1e4edfefbb70'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('input_types',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('first_name', sa.String(), nullable=True),
    sa.Column('last_name', sa.String(), nullable=True),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('locations',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('zipcode', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'user_id', name='_location_user_uc')
    )
    op.create_table('groups',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('location_id', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['location_id'], ['locations.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'location_id', name='_group_location_uc')
    )
    op.create_table('zones',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('group_id', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['group_id'], ['groups.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'group_id', name='_zone_group_uc')
    )
    op.create_table('inputs',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('input_type_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('zone_id', sa.Integer(), nullable=True),
    sa.Column('fingerprint', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['input_type_id'], ['input_types.id'], ),
    sa.ForeignKeyConstraint(['zone_id'], ['zones.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'zone_id', name='_input_zone_uc')
    )
    op.create_table('mqtt_events',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('input_id', sa.Integer(), nullable=True),
    sa.Column('data_load', sa.JSON(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['input_id'], ['inputs.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('timed_events',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('input_id', sa.Integer(), nullable=False),
    sa.Column('cron_job', sa.String(), nullable=False),
    sa.Column('message', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['input_id'], ['inputs.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('triggered_events',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('input_id', sa.Integer(), nullable=False),
    sa.Column('output_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['input_id'], ['inputs.id'], ),
    sa.ForeignKeyConstraint(['output_id'], ['inputs.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('triggered_events')
    op.drop_table('timed_events')
    op.drop_table('mqtt_events')
    op.drop_table('inputs')
    op.drop_table('zones')
    op.drop_table('groups')
    op.drop_table('locations')
    op.drop_table('users')
    op.drop_table('input_types')
    # ### end Alembic commands ###
