code: def downgrade():
      with op.batch_alter_table("integration", schema=None) as batch_op:
          batch_op.drop_constraint(
              "unique_integration_name_company_id", type_="unique"
          )
  
      with op.batch_alter_table("predictor", schema=None) as batch_op:
          batch_op.drop_constraint(
              "unique_predictor_name_company_id", type_="unique"
          )
  
      with op.batch_alter_table("dataset", schema=None) as batch_op:
          batch_op.drop_constraint(
              "unique_dataset_name_company_id", type_="unique"
          )
  
      with op.batch_alter_table("predictor", schema=None) as batch_op:
          batch_op.drop_constraint(
              "fk_predictor_dataset_id", type_="foreignkey"
          )
          batch_op.alter_column(
              "dataset_id", new_column_name="datasource_id"
          )
  
      with op.batch_alter_table("dataset", schema=None) as batch_op:
          batch_op.drop_constraint(
              "fk_integration_id", type_="foreignkey"
          )
          batch_op.add_column(
              sa.Column("analysis", sa.VARCHAR(), nullable=True)
          )
          batch_op.drop_constraint(
              "fk_ds_analysis_id", type_="foreignkey"
          )
          batch_op.drop_column("ds_class")
  
      op.rename_table("dataset", "datasource")
  
      op.drop_table("file")
  
      conn = op.get_bind()
      conn.execute(
          text(
              """
          update datasource set analysis = (select analysis from analysis where id = analysis_id)
      """
          )
      )
  
      with op.batch_alter_table("datasource", schema=None) as batch_op:
          batch_op.drop_column("analysis_id")
  
      op.drop_table("analysis")
  
      op.create_table(
          "ai_table",
          sa.Column("id", sa.Integer(), nullable=False),
          sa.Column("updated_at", sa.DateTime(), nullable=True),
          sa.Column("created_at", sa.DateTime(), nullable=True),
          sa.Column("name", sa.String(), nullable=False),
          sa.Column("integration_name", sa.String(), nullable=False),
          sa.Column("integration_query", sa.String(), nullable=False),
          sa.Column(
              "query_fields",
              mindsdb.interfaces.storage.db.Json(),
              nullable=False,
          ),
          sa.Column("predictor_name", sa.String(), nullable=False),
          sa.Column(
              "predictor_columns",
              mindsdb.interfaces.storage.db.Json(),
              nullable=False,
          ),
          sa.Column("company_id", sa.Integer(), nullable=True),
          sa.PrimaryKeyConstraint("id"),
      )
  
      op.create_table(
          "view_tmp",
          sa.Column("id", sa.Integer(), nullable=False),
          sa.Column("name", sa.String(), nullable=False),
          sa.Column("company_id", sa.Integer(), nullable=True),
          sa.Column("query", sa.String(), nullable=False),
          sa.Column("datasource_id", sa.Integer(), nullable=False),
          sa.ForeignKeyConstraint(
              ["datasource_id"],
              ["integration.id"],
              name="fk_datasource_id",
          ),
          sa.PrimaryKeyConstraint("id"),
          sa.UniqueConstraint(
              "name", "company_id", name="unique_name_company_id"
          ),
      )
      conn.execute(
          text(
              """
          insert into view_tmp (id, name, company_id, query, datasource_id)
          select id, name, company_id, query, integration_id from view;
      """
          )
      )
      op.drop_table("view")
      op.rename_table("view_tmp", "view")
  
imports: import json
  import datetime
  from alembic import op
  import sqlalchemy
  import mindsdb.interfaces.storage.db
  from sqlalchemy.sql import text
label_desc: Use image node_id 2 for calling a global function with example usage: downgrade() without return types