"""onsite baseline july 2017

Revision ID: a68c0e31204e
Revises:
Create Date: 2017-07-13 01:51:59.044973+00:00

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

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "autocorrelations",
        sa.Column("id", sa.BigInteger(), nullable=False),
        sa.Column("time", sa.DateTime(), nullable=False),
        sa.Column("antnum", sa.Integer(), nullable=False),
        sa.Column("polarization", sa.String(length=1), nullable=False),
        sa.Column("measurement_type", sa.SmallInteger(), nullable=False),
        sa.Column("value", sa.Float(precision="53"), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "hera_obs",
        sa.Column("obsid", sa.BigInteger(), nullable=False),
        sa.Column("start_time_jd", postgresql.DOUBLE_PRECISION(), nullable=False),
        sa.Column("stop_time_jd", postgresql.DOUBLE_PRECISION(), nullable=False),
        sa.Column("lst_start_hr", postgresql.DOUBLE_PRECISION(), nullable=False),
        sa.PrimaryKeyConstraint("obsid"),
    )
    op.create_table(
        "host_status",
        sa.Column("id", sa.BigInteger(), nullable=False),
        sa.Column("time", sa.DateTime(), nullable=False),
        sa.Column("hostname", sa.String(length=64), nullable=True),
        sa.Column("load_average", sa.Float(), nullable=False),
        sa.Column("uptime", sa.Float(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "paper_temperatures",
        sa.Column("gps_time", postgresql.DOUBLE_PRECISION(), nullable=False),
        sa.Column("jd_time", postgresql.DOUBLE_PRECISION(), nullable=False),
        sa.Column("balun_east", sa.Float(), nullable=True),
        sa.Column("cable_east", sa.Float(), nullable=True),
        sa.Column("balun_west", sa.Float(), nullable=True),
        sa.Column("cable_west", sa.Float(), nullable=True),
        sa.Column("rcvr_1a", sa.Float(), nullable=True),
        sa.Column("rcvr_1b", sa.Float(), nullable=True),
        sa.Column("rcvr_2a", sa.Float(), nullable=True),
        sa.Column("rcvr_2b", sa.Float(), nullable=True),
        sa.Column("rcvr_3a", sa.Float(), nullable=True),
        sa.Column("rcvr_3b", sa.Float(), nullable=True),
        sa.Column("rcvr_4a", sa.Float(), nullable=True),
        sa.Column("rcvr_4b", sa.Float(), nullable=True),
        sa.Column("rcvr_5a", sa.Float(), nullable=True),
        sa.Column("rcvr_5b", sa.Float(), nullable=True),
        sa.Column("rcvr_6a", sa.Float(), nullable=True),
        sa.Column("rcvr_6b", sa.Float(), nullable=True),
        sa.Column("rcvr_7a", sa.Float(), nullable=True),
        sa.Column("rcvr_7b", sa.Float(), nullable=True),
        sa.Column("rcvr_8a", sa.Float(), nullable=True),
        sa.Column("rcvr_8b", sa.Float(), nullable=True),
        sa.PrimaryKeyConstraint("gps_time"),
    )
    op.create_table(
        "part_info",
        sa.Column("hpn", sa.String(length=64), nullable=False),
        sa.Column("hpn_rev", sa.String(length=32), nullable=False),
        sa.Column("posting_date", sa.DateTime(timezone=True), nullable=False),
        sa.Column("comment", sa.String(length=2048), nullable=False),
        sa.Column("library_file", sa.String(length=256), nullable=True),
        sa.PrimaryKeyConstraint("hpn", "hpn_rev", "posting_date"),
    )
    op.create_table(
        "parts_paper",
        sa.Column("hpn", sa.String(length=64), nullable=False),
        sa.Column("hpn_rev", sa.String(length=32), nullable=False),
        sa.Column("hptype", sa.String(length=64), nullable=False),
        sa.Column("manufacturer_number", sa.String(length=64), nullable=True),
        sa.Column("start_date", sa.DateTime(timezone=True), nullable=False),
        sa.Column("stop_date", sa.DateTime(timezone=True), nullable=True),
        sa.PrimaryKeyConstraint("hpn", "hpn_rev"),
    )
    op.create_table(
        "station_type",
        sa.Column("station_type_name", sa.String(length=64), nullable=False),
        sa.Column("prefix", sa.String(length=64), nullable=False),
        sa.Column("description", sa.String(length=64), nullable=True),
        sa.Column("plot_marker", sa.String(length=64), nullable=True),
        sa.PrimaryKeyConstraint("station_type_name"),
    )
    op.create_table(
        "connections",
        sa.Column("upstream_part", sa.String(length=64), nullable=False),
        sa.Column("up_part_rev", sa.String(length=32), nullable=False),
        sa.Column("downstream_part", sa.String(length=64), nullable=False),
        sa.Column("down_part_rev", sa.String(length=64), nullable=False),
        sa.Column("upstream_output_port", sa.String(length=64), nullable=False),
        sa.Column("downstream_input_port", sa.String(length=64), nullable=False),
        sa.Column("start_date", sa.DateTime(timezone=True), nullable=False),
        sa.Column("stop_date", sa.DateTime(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(
            ["downstream_part", "down_part_rev"],
            ["parts_paper.hpn", "parts_paper.hpn_rev"],
        ),
        sa.ForeignKeyConstraint(
            ["upstream_part", "up_part_rev"],
            ["parts_paper.hpn", "parts_paper.hpn_rev"],
        ),
        sa.PrimaryKeyConstraint(
            "upstream_part",
            "up_part_rev",
            "downstream_part",
            "down_part_rev",
            "upstream_output_port",
            "downstream_input_port",
            "start_date",
        ),
    )
    op.create_table(
        "geo_location",
        sa.Column("station_name", sa.String(length=64), nullable=False),
        sa.Column("station_type_name", sa.String(length=64), nullable=False),
        sa.Column("datum", sa.String(length=64), nullable=True),
        sa.Column("tile", sa.String(length=64), nullable=True),
        sa.Column("northing", sa.Float(precision="53"), nullable=True),
        sa.Column("easting", sa.Float(precision="53"), nullable=True),
        sa.Column("elevation", sa.Float(), nullable=True),
        sa.Column("created_date", sa.DateTime(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["station_type_name"],
            ["station_type.station_type_name"],
        ),
        sa.PrimaryKeyConstraint("station_name"),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("geo_location")
    op.drop_table("connections")
    op.drop_table("station_type")
    op.drop_table("parts_paper")
    op.drop_table("part_info")
    op.drop_table("paper_temperatures")
    op.drop_table("host_status")
    op.drop_table("hera_obs")
    op.drop_table("autocorrelations")
    # ### end Alembic commands ###
