text: # Copyright (c) 2014-present, Facebook, Inc.
  """rename columns and table
  
  Revision ID: 0002
  Revises: 0001
  Create Date: 2020-06-11 20:35:53.940083
  
  """
  import sqlalchemy as sa
  from alembic import op
  
  
  # revision identifiers, used by Alembic.
  revision = "0002"
  down_revision = "0001"
  branch_labels = None
  depends_on = None
  
  
  def upgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.create_table(
          "cn_egress_routes_history",
          sa.Column("id", sa.Integer(), nullable=False),
          sa.Column("network_name", sa.String(length=100), nullable=False),
          sa.Column("link_name", sa.String(length=255), nullable=False),
          sa.Column("last_updated", sa.DateTime(), nullable=False),
          sa.Column("routes", sa.JSON(), nullable=False),
          sa.PrimaryKeyConstraint("id"),
      )
      op.create_index(
          op.f("ix_cn_egress_routes_history_last_updated"),
          "cn_egress_routes_history",
          ["last_updated"],
          unique=False,
      )
      op.create_index(
          op.f("ix_cn_egress_routes_history_link_name"),
          "cn_egress_routes_history",
          ["link_name"],
          unique=False,
      )
      op.create_index(
          op.f("ix_cn_egress_routes_history_network_name"),
          "cn_egress_routes_history",
          ["network_name"],
          unique=False,
      )
      op.drop_index("ix_link_cn_routes_last_updated", table_name="link_cn_routes")
      op.drop_index("ix_link_cn_routes_link_name", table_name="link_cn_routes")
      op.drop_index("ix_link_cn_routes_network_name", table_name="link_cn_routes")
      op.drop_table("link_cn_routes")
      op.add_column(
          "default_routes_history",
          sa.Column("max_hop_count", sa.Integer(), nullable=False),
      )
      op.drop_column("default_routes_history", "hop_count")
      # ### end Alembic commands ###
  
  
  def downgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.add_column(
          "default_routes_history",
          sa.Column("hop_count", sa.Integer(), autoincrement=False, nullable=False),
      )
      op.drop_column("default_routes_history", "max_hop_count")
      op.create_table(
          "link_cn_routes",
          sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
          sa.Column("network_name", sa.String(length=100), nullable=False),
          sa.Column("link_name", sa.String(length=255), nullable=False),
          sa.Column("last_updated", sa.DateTime(), nullable=False),
          sa.Column("cn_routes", sa.JSON(), nullable=False),
          sa.PrimaryKeyConstraint("id"),
      )
      op.create_index(
          "ix_link_cn_routes_network_name",
          "link_cn_routes",
          ["network_name"],
          unique=False,
      )
      op.create_index(
          "ix_link_cn_routes_link_name", "link_cn_routes", ["link_name"], unique=False
      )
      op.create_index(
          "ix_link_cn_routes_last_updated",
          "link_cn_routes",
          ["last_updated"],
          unique=False,
      )
      op.drop_index(
          op.f("ix_cn_egress_routes_history_network_name"),
          table_name="cn_egress_routes_history",
      )
      op.drop_index(
          op.f("ix_cn_egress_routes_history_link_name"),
          table_name="cn_egress_routes_history",
      )
      op.drop_index(
          op.f("ix_cn_egress_routes_history_last_updated"),
          table_name="cn_egress_routes_history",
      )
      op.drop_table("cn_egress_routes_history")
      # ### end Alembic commands ###
  