code: def downgrade():
      bind = op.get_bind()
      session = db.Session(bind=bind)
  
      dashboards = (
          session.query(Dashboard)
          .filter(
              Dashboard.json_metadata.like(
                  '%"native_filter_configuration"%'
              )
          )
          .all()
      )
      changed_filters, changed_filter_sets = 0, 0
      for dashboard in dashboards:
          try:
              json_metadata = json.loads(dashboard.json_metadata)
              downgrades = downgrade_dashboard(json_metadata)
              changed_filters += downgrades[0]
              changed_filter_sets += downgrades[1]
              dashboard.json_metadata = json.dumps(
                  json_metadata, sort_keys=True
              )
          except Exception as e:
              print(
                  f"Parsing json_metadata for dashboard {dashboard.id} failed."
              )
              raise e
  
      session.commit()
      session.close()
      print(
          f"Downgraded {changed_filters} filters and {changed_filter_sets} filter sets."
      )
  
file_path: superset/superset/migrations/versions/2021-04-29_15-32_f1410ed7ec95_migrate_native_filters_to_new_schema.py
imports: import json
  from collections.abc import Iterable
  from typing import Any
  from alembic import op
  from sqlalchemy import Column, Integer, Text
  from sqlalchemy.ext.declarative import declarative_base
  from superset import db
label_desc: Use image node_id 6 for calling a global function with example usage: downgrade() without return types