code: def _migrate_dataset_if_necessary(name, destination, verbose):
      if _migrations_disabled():
          return
  
      head = get_dataset_revision(name)
      db_version = get_database_revision()
  
      if head is None:
          head = "0.0"
  
      default_destination = destination is None
  
      if default_destination:
          if _can_skip_migration(head):
              return
  
          destination = db_version
  
      if head == destination:
          return
  
      if not fo.config.database_admin and destination != db_version:
          if default_destination:
              if foc.COMPATIBLE_VERSIONS:
                  compat_str = (
                      " (compatibility %s)" % foc.COMPATIBLE_VERSIONS
                  )
              else:
                  compat_str = ""
  
              raise EnvironmentError(
                  "Cannot load dataset '%s' from v%s with client v%s%s. "
                  "See https://docs.voxel51.com/user_guide/config.html#database-migrations "
                  "for more information"
                  % (name, head, foc.VERSION, compat_str)
              )
          else:
              raise EnvironmentError(
                  "Cannot migrate dataset '%s' from v%s to v%s when database_admin=%s."
                  "See https://docs.voxel51.com/user_guide/config.html#database-migrations "
                  "for more information"
                  % (name, head, destination, fo.config.database_admin)
              )
  
      runner = MigrationRunner(head, destination)
      if runner.has_revisions:
          logger.info(
              "Migrating dataset '%s' to v%s", name, destination
          )
          runner.run(name, verbose=verbose)
  
      if Version(destination) >= Version("0.6.2"):
          conn = foo.get_db_conn()
          conn.datasets.update_one(
              {"name": name}, {"$set": {"version": destination}}
          )
      else:
          # Old version of FiftyOne that didn't store dataset versions
          pass
  
imports: import bisect
  import logging
  import os
  from packaging.requirements import Requirement
  from packaging.version import Version
  import eta.core.utils
  import fiftyone
  import fiftyone.constants
  import fiftyone.core.odm
  import fiftyone.core.utils
label_desc: Use image node_id 9 for calling a global function with example usage: _migrate_dataset_if_necessary(name, destination, verbose) without return types