code: def upgrade():
      bind = op.get_bind()
      session = db.Session(bind=bind)
  
      # Delete the orphaned columns records.
      for record in session.query(DruidColumn).all():
          if record.datasource_id is None:
              session.delete(record)
  
      session.commit()
  
      # Enforce that the columns.column_name column be non-nullable.
      with op.batch_alter_table("columns") as batch_op:
          batch_op.alter_column(
              "column_name", existing_type=String(255), nullable=False
          )
  
      # Delete the orphaned table_columns records.
      for record in session.query(TableColumn).all():
          if record.table_id is None:
              session.delete(record)
  
      session.commit()
  
      # Reduce the size of the table_columns.column_name column for constraint
      # viability and enforce that it be non-nullable.
      with op.batch_alter_table("table_columns") as batch_op:
          batch_op.alter_column(
              "column_name",
              existing_type=String(256),
              nullable=False,
              type_=String(255),
          )
  
      # Add the missing uniqueness constraint to the table_columns table.
      with op.batch_alter_table(
          "table_columns", naming_convention=conv
      ) as batch_op:
          batch_op.create_unique_constraint(
              "uq_table_columns_column_name",
              ["column_name", "table_id"],
          )
  
file_path: superset/superset/migrations/versions/2018-07-20_15-31_7f2635b51f5d_update_base_columns.py
imports: from alembic import op
  from sqlalchemy import Column, engine, Integer, String
  from sqlalchemy.ext.declarative import declarative_base
  from superset import db
  from superset.utils.core import generic_find_uq_constraint_name
label_desc: Use image node_id 1 for calling a global function with example usage: upgrade() without return types