"""sensor_readings_table

Revision ID: 2b4a8557e3ae
Revises:
Create Date: 2019-05-27 19:44:02.428231

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

# revision identifiers, used by Alembic.
revision = "2b4a8557e3ae"
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "sensor_reading",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("date", sa.DateTime(), nullable=True),
        sa.Column("device_id", sa.String(length=64), nullable=True),
        sa.Column("msg", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_sensor_reading_device_id"), "sensor_reading", ["device_id"], unique=False
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_sensor_reading_device_id"), table_name="sensor_reading")
    op.drop_table("sensor_reading")
    # ### end Alembic commands ###
