code: def _downgrade_v5(op):
      op.create_table(
          "_new_equities",
          sa.Column(
              "sid",
              sa.Integer,
              unique=True,
              nullable=False,
              primary_key=True,
          ),
          sa.Column("symbol", sa.Text),
          sa.Column("company_symbol", sa.Text),
          sa.Column("share_class_symbol", sa.Text),
          sa.Column("fuzzy_symbol", sa.Text),
          sa.Column("asset_name", sa.Text),
          sa.Column(
              "start_date", sa.Integer, default=0, nullable=False
          ),
          sa.Column("end_date", sa.Integer, nullable=False),
          sa.Column("first_traded", sa.Integer),
          sa.Column("auto_close_date", sa.Integer),
          sa.Column("exchange", sa.Text),
          sa.Column("exchange_full", sa.Text),
      )
  
      op.execute(
          """
          insert into _new_equities
          select
              equities.sid as sid,
              sym.symbol as symbol,
              sym.company_symbol as company_symbol,
              sym.share_class_symbol as share_class_symbol,
              sym.company_symbol || sym.share_class_symbol as fuzzy_symbol,
              equities.asset_name as asset_name,
              equities.start_date as start_date,
              equities.end_date as end_date,
              equities.first_traded as first_traded,
              equities.auto_close_date as auto_close_date,
              equities.exchange as exchange,
              equities.exchange_full as exchange_full
          from
              equities
          inner join
              -- Nested select here to take the most recently held ticker
              -- for each sid. The group by with no aggregation function will
              -- take the last element in the group, so we first order by
              -- the end date ascending to ensure that the groupby takes
              -- the last ticker.
              (select
                   *
               from
                   (select
                        *
                    from
                        equity_symbol_mappings
                    order by
                        equity_symbol_mappings.end_date asc)
               group by
                   sid) sym
          on
              equities.sid == sym.sid
          """,
      )
      op.drop_table("equity_symbol_mappings")
      op.drop_table("equities")
      op.rename_table("_new_equities", "equities")
      # we need to make sure the indicies have the proper names after the rename
      op.create_index(
          "ix_equities_company_symbol",
          "equities",
          ["company_symbol"],
      )
      op.create_index(
          "ix_equities_fuzzy_symbol",
          "equities",
          ["fuzzy_symbol"],
      )
  
file_path: catalyst/catalyst/assets/asset_db_migrations.py
imports: from functools import wraps
  from alembic.migration import MigrationContext
  from alembic.operations import Operations
  import sqlalchemy
  from toolz.curried import do, operator
  from catalyst.assets.asset_writer import write_version_info
  from catalyst.errors import AssetDBImpossibleDowngrade
  from catalyst.utils.preprocess import preprocess
  from catalyst.utils.sqlite_utils import coerce_string_to_eng
label_desc: Use image node_id 8 for calling a global function with example usage: _downgrade_v5(op) without return types