code: def upgrade():
      bind = op.get_bind()
      session = orm.Session(bind=bind)
  
      with op.batch_alter_table("trials") as batch_op:
          batch_op.add_column(
              sa.Column(
                  "number", sa.Integer(), nullable=True, default=None
              )
          )
  
      try:
          number_records = (
              session.query(TrialSystemAttributeModel)
              .filter(TrialSystemAttributeModel.key == "_number")
              .all()
          )
          mapping = [
              {
                  "trial_id": r.trial_id,
                  "number": json.loads(r.value_json),
              }
              for r in number_records
          ]
          session.bulk_update_mappings(TrialModel, mapping)
  
          stmt = (
              sa.delete(TrialSystemAttributeModel)
              .where(TrialSystemAttributeModel.key == "_number")
              .execution_options(synchronize_session=False)
          )
          session.execute(stmt)
          session.commit()
      except SQLAlchemyError as e:
          session.rollback()
          raise e
      finally:
          session.close()
  
file_path: optuna/optuna/storages/_rdb/alembic/versions/v1.3.0.a.py
imports: import json
  from alembic import op
  import sqlalchemy
  from sqlalchemy.exc import SQLAlchemyError
  from sqlalchemy import orm
label_desc: Use image node_id 1 for calling a global function with example usage: upgrade() without return types