code: def upgrade():
      bind = op.get_bind()
      session = db.Session(bind=bind)
  
      op.execute(
          insert(DatasetUser).from_select(
              ["user_id", "dataset_id"],
              session.query(Dataset.created_by_fk, Dataset.id)
              .outerjoin(
                  DatasetUser,
                  and_(
                      DatasetUser.dataset_id == Dataset.id,
                      DatasetUser.user_id == Dataset.created_by_fk,
                  ),
              )
              .filter(
                  DatasetUser.dataset_id == None,
                  Dataset.created_by_fk != None,
              ),
          )
      )
  
      op.execute(
          insert(SliceUser).from_select(
              ["user_id", "slice_id"],
              session.query(Slice.created_by_fk, Slice.id)
              .outerjoin(
                  SliceUser,
                  and_(
                      SliceUser.slice_id == Slice.id,
                      SliceUser.user_id == Slice.created_by_fk,
                  ),
              )
              .filter(SliceUser.slice_id == None),
          )
      )
  
      op.execute(
          insert(SqlaTableUser).from_select(
              ["user_id", "table_id"],
              session.query(SqlaTable.created_by_fk, SqlaTable.id)
              .outerjoin(
                  SqlaTableUser,
                  and_(
                      SqlaTableUser.table_id == SqlaTable.id,
                      SqlaTableUser.user_id == SqlaTable.created_by_fk,
                  ),
              )
              .filter(SqlaTableUser.table_id == None),
          )
      )
  
file_path: superset/superset/migrations/versions/2022-07-05_15-48_409c7b420ab0_add_created_by_fk_as_owner.py
imports: from alembic import op
  from sqlalchemy import and_, Column, insert, Integer
  from sqlalchemy.ext.declarative import declarative_base
  from superset import db
label_desc: Use image node_id 1 for calling a global function with example usage: upgrade() without return types