"""adding qm tables

Revision ID: e66c069eb92b
Revises: 3e86ac6195d8
Create Date: 2017-08-04 23:04:23.097038+00:00

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "e66c069eb92b"
down_revision = "3e86ac6195d8"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "metric_list",
        sa.Column("metric", sa.String(), nullable=False),
        sa.Column("desc", sa.String(), nullable=False),
        sa.PrimaryKeyConstraint("metric"),
    )
    op.create_table(
        "ant_metrics",
        sa.Column("obsid", sa.BigInteger(), nullable=False),
        sa.Column("ant", sa.Integer(), nullable=False),
        sa.Column("pol", sa.String(), nullable=False),
        sa.Column("metric", sa.String(), nullable=False),
        sa.Column("mc_time", sa.BigInteger(), nullable=False),
        sa.Column("val", sa.Float(), nullable=False),
        sa.ForeignKeyConstraint(
            ["metric"],
            ["metric_list.metric"],
        ),
        sa.ForeignKeyConstraint(
            ["obsid"],
            ["hera_obs.obsid"],
        ),
        sa.PrimaryKeyConstraint("obsid", "ant", "pol", "metric"),
    )
    op.create_table(
        "array_metrics",
        sa.Column("obsid", sa.BigInteger(), nullable=False),
        sa.Column("metric", sa.String(), nullable=False),
        sa.Column("mc_time", sa.BigInteger(), nullable=False),
        sa.Column("val", sa.Float(), nullable=False),
        sa.ForeignKeyConstraint(
            ["metric"],
            ["metric_list.metric"],
        ),
        sa.ForeignKeyConstraint(
            ["obsid"],
            ["hera_obs.obsid"],
        ),
        sa.PrimaryKeyConstraint("obsid", "metric"),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("array_metrics")
    op.drop_table("ant_metrics")
    op.drop_table("metric_list")
    # ### end Alembic commands ###
