You are here

function hosting_migrate_comparison in Hostmaster (Aegir) 6

Compare package schema versions between the current and target platform in temp tables

1 string reference to 'hosting_migrate_comparison'
hosting_migrate_menu in modules/hosting/migrate/hosting_migrate.module
Implementation of hook_menu().

File

modules/hosting/migrate/hosting_migrate.module, line 205

Code

function hosting_migrate_comparison($current, $target) {
  $current_tbl = _hosting_package_temporary_table($current);
  $target_tbl = _hosting_package_temporary_table($target);
  $packages = array();
  $result = db_query("SELECT c.nid, c.short_name, \n    c.version as current_version, t.version as target_version,\n    c.version_code as current_version_code, t.version_code as target_version_code,\n    c.schema_version as current_schema, t.schema_version as target_schema, c.status AS enabled \n    FROM %s c LEFT JOIN %s t ON c.nid = t.nid ORDER BY c.status DESC, short_name", $current_tbl, $target_tbl);
  while ($obj = db_fetch_object($result)) {
    if (isset($obj->current_schema) && (int) $obj->target_schema > 0 && (int) $obj->current_schema > (int) $obj->target_schema) {
      $obj->status = 'downgrade';
    }
    elseif ($obj->current_version_code > $obj->target_version_code || is_null($obj->target_version_code)) {
      $obj->status = 'missing';
    }
    elseif ($obj->current_version_code < $obj->target_version_code || $obj->current_schema < $obj->target_schema) {
      $obj->status = 'upgrade';
    }
    else {
      $obj->status = 'same';
    }
    $packages[$obj->nid] = $obj;
  }
  return theme("hosting_migrate_comparison", $packages);
}