code: def upgrade():
      with op.batch_alter_table("predictor", schema=None) as batch_op:
          batch_op.add_column(
              sa.Column("status", sa.String(), nullable=True)
          )
  
      conn = op.get_bind()
      session = sa.orm.Session(bind=conn)
      predictors = conn.execute(
          text(
              """
          select id, data, update_status, json_ai, code from predictor
      """
          )
      ).fetchall()
  
      for row in predictors:
          try:
              data = json.loads(row["data"])
          except Exception:
              data = None
  
          status = None
          # assume older models are complete, only temporary
          if "status" in (data or {}):
              status = data["status"]
          elif "error" in (data or {}):
              status = "error"
          elif row["update_status"] == "available":
              status = "complete"
          elif row["json_ai"] is None and row["code"] is None:
              status = "generating"
          elif data is None:
              status = "error"
          elif "training_log" in (data or {}):
              status = "training"
          elif "error" not in (data or {}):
              status = "complete"
          else:
              status = "error"
  
          conn.execute(
              text(
                  """
                  update predictor
                  set status = :status
                  where id = :predictor_id
              """
              ),
              {"status": status, "predictor_id": row["id"]},
          )
      session.commit()
  
imports: import json
  from alembic import op
  import sqlalchemy
  from sqlalchemy.sql import text
  import mindsdb.interfaces.storage.db
label_desc: Use image node_id 1 for calling a global function with example usage: upgrade() without return types