code: def upgrade():
      # We previously had a KnownEvent's table, but we deleted the table without
      # a down migration to remove it (so we didn't delete anyone's data if they
      # were happening to use the feature.
      #
      # But before we can delete the users table we need to drop the FK
  
      conn = op.get_bind()
      inspector = inspect(conn)
      tables = inspector.get_table_names()
  
      if "known_event" in tables:
          for fkey in inspector.get_foreign_keys(
              table_name="known_event", referred_table="users"
          ):
              if fkey["name"]:
                  with op.batch_alter_table(
                      table_name="known_event"
                  ) as bop:
                      bop.drop_constraint(
                          fkey["name"], type_="foreignkey"
                      )
  
      if "chart" in tables:
          op.drop_table(
              "chart",
          )
  
      if "users" in tables:
          op.drop_table("users")
  
imports: from __future__ import annotations
  import sqlalchemy
  from alembic import op
  from sqlalchemy import inspect, text
  from sqlalchemy.dialects import mysql
label_desc: Use image node_id 1 for calling a global function with example usage: upgrade() without return types