"""root-stats

Revision ID: 503a2cef2378
Revises: aa2dfb4decda
Create Date: 2018-03-25 22:20:39.436208

"""

# revision identifiers, used by Alembic.
revision = "503a2cef2378"
down_revision = "aa2dfb4decda"
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


from sqlalchemy_utils import UUIDType as TempUUIDType

UUIDType = TempUUIDType(binary=False)


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "rb_root_cache",
        sa.Column("id", UUIDType, nullable=False),
        sa.Column("root_id", UUIDType, nullable=True),
        sa.Column("valid", sa.Boolean(), nullable=True),
        sa.Column("updated_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("json_stats", sa.UnicodeText(), nullable=True),
        sa.ForeignKeyConstraint(["root_id"], ["rb_node.id"]),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_rb_root_cache_id"), "rb_root_cache", ["id"], unique=False)
    op.create_index(
        op.f("ix_rb_root_cache_root_id"), "rb_root_cache", ["root_id"], unique=False
    )
    # ### end Alembic commands ###


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