You are here

function hosting_package_comparison in Hostmaster (Aegir) 6

2 calls to hosting_package_comparison()
hosting_migrate_platform_batch in modules/hosting/migrate/hosting_migrate.batch.inc
Batch comparison of site packages between platforms to determine if the site can be migrated to the target platform or not.
hosting_task_migrate_form in modules/hosting/migrate/hosting_migrate.module
Implementation of hook_form().

File

modules/hosting/package/hosting_package.instance.inc, line 234
API for mapping packages to various Hosting node types

Code

function hosting_package_comparison($current, $target) {
  $current_tbl = _hosting_package_temporary_table($current);
  $target_tbl = _hosting_package_temporary_table($target);
  $status = array();
  $result = db_query("SELECT count(c.nid) AS error FROM %s c LEFT JOIN %s t ON c.nid=t.nid WHERE (t.schema_version > 0) && (c.schema_version > t.schema_version) AND c.status=1", $current_tbl, $target_tbl);
  while ($obj = db_fetch_object($result)) {
    $status['error'] = $obj->error;
  }
  $result = db_query("SELECT COUNT(c.nid) as missing FROM %s c LEFT JOIN %s t ON c.nid=t.nid WHERE t.nid IS null AND c.status=1", $current_tbl, $target_tbl);
  while ($obj = db_fetch_object($result)) {
    $status['missing'] = $obj->missing;
  }
  $result = db_query("SELECT COUNT(c.nid) as upgrade FROM %s c LEFT JOIN %s t ON c.nid=t.nid WHERE (c.version_code < t.version_code) OR (c.schema_version < t.schema_version) AND c.status=1", $current_tbl, $target_tbl);
  while ($obj = db_fetch_object($result)) {
    $status['upgrade'] = $obj->upgrade;
  }
  $result = db_query("SELECT count(c.nid) AS downgrade FROM %s c LEFT JOIN %s t ON c.nid=t.nid WHERE (c.version_code > t.version_code)", $current_tbl, $target_tbl);
  while ($obj = db_fetch_object($result)) {
    $status['downgrade'] = $obj->downgrade;
  }
  return $status;
}