code: def upgrade():
      conn = op.get_bind()
      session = sa.orm.Session(bind=conn)
      conn.execute(
          text(
              """
          delete from file
          where exists (
              select 1 from file as t2
              where file.name = t2.name
                    and file.company_id = t2.company_id
                    and file.id < t2.id
          )
      """
          )
      )
      session.commit()
  
      with op.batch_alter_table("file", schema=None) as batch_op:
          batch_op.create_unique_constraint(
              "unique_file_name_company_id", ["name", "company_id"]
          )
  
      conn.execute(
          text(
              """
          delete from integration where engine is null
      """
          )
      )
      session.commit()
  
      with op.batch_alter_table("integration", schema=None) as batch_op:
          batch_op.alter_column(
              "engine", existing_type=sa.VARCHAR(), nullable=False
          )
  
      with op.batch_alter_table("predictor", schema=None) as batch_op:
          batch_op.drop_constraint(
              "unique_predictor_name_company_id", type_="unique"
          )
  
      conn.execute(
          text(
              """
          delete from semaphor
      """
          )
      )
      session.commit()
  
      try:
          with op.batch_alter_table(
              "semaphor", schema=None
          ) as batch_op:
              batch_op.create_unique_constraint(
                  "uniq_const", ["entity_type", "entity_id"]
              )
      except Exception:
          pass
  
imports: 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