"""empty message

Revision ID: 37888cac6b2b
Revises: c8a4fb7e085a
Create Date: 2019-07-09 11:08:38.802480

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

# revision identifiers, used by Alembic.
revision = "37888cac6b2b"
down_revision = "c8a4fb7e085a"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "trial_metadata",
        sa.Column("_created", sa.DateTime(), nullable=True),
        sa.Column("_updated", sa.DateTime(), nullable=True),
        sa.Column("_etag", sa.String(length=40), nullable=True),
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("trial_id", sa.String(), nullable=False),
        sa.Column(
            "metadata_json", postgresql.JSONB(astext_type=sa.Text()), nullable=False
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_trial_metadata_trial_id"), "trial_metadata", ["trial_id"], unique=True
    )
    op.create_index(
        "metadata_idx",
        "trial_metadata",
        ["metadata_json"],
        unique=False,
        postgresql_using="gin",
    )
    # ### end Alembic commands ###


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