You are here

hosting_web_server.install in Hosting 6.2

File

web_server/hosting_web_server.install
View source
<?php

/**
 * Add package description to hosting_package table
 */
function hosting_web_server_update_1() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE {hosting_web_server} ADD COLUMN drush_path longtext NOT NULL default ''");
  return $ret;
}
function hosting_web_server_update_2() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE {hosting_web_server} ADD COLUMN ports longtext NOT NULL default ''");
  db_query("UPDATE {hosting_web_server} SET ports = '80'");
  return $ret;
}

/**
 * Move a lot of fields to the hosting_server table.
 */
function hosting_web_server_update_6000() {
  $ret = array();

  // THIS IS A MYSQL-ism, but we need it at this point.
  db_query("INSERT INTO {hosting_service} (nid, vid, service, type, restart_cmd, port, available) SELECT nid, vid, 'http', 'apache', restart_cmd, 80, 1 FROM {hosting_web_server}");
  db_query("INSERT INTO {hosting_server} (nid, vid) SELECT nid, vid FROM {hosting_web_server}");
  db_query("UPDATE {node} SET type='server' WHERE type='web_server'");
  db_drop_field($ret, "hosting_web_server", "ip_address");
  db_drop_field($ret, "hosting_web_server", "script_user");
  db_drop_field($ret, "hosting_web_server", "backup_path");
  db_drop_field($ret, "hosting_web_server", "config_path");
  db_drop_field($ret, "hosting_web_server", "drush_path");
  return $ret;
}

/**
 * Remove the web_group field which now needs to be consistent between servers.
 */
function hosting_web_server_update_6001() {
  $ret = array();
  db_drop_field($ret, "hosting_web_server", "web_group");
  return $ret;
}

/**
 * Drop the web_server table as it is no longer needed..
 * Move the restart command value into it's new home in the service table.
 */
function hosting_web_server_update_6002() {
  $ret = array();
  $result = db_query("SELECT * FROM {hosting_web_server}");
  while ($obj = db_fetch_object($result)) {
    db_query("UPDATE {hosting_service} SET restart_cmd = '%s', port = 80 WHERE nid=%d AND service='http' AND type = 'apache'", $obj->restart_cmd, $obj->nid);
  }
  db_drop_table($ret, 'hosting_web_server');
  return $ret;
}

Functions

Namesort descending Description
hosting_web_server_update_1 Add package description to hosting_package table
hosting_web_server_update_2
hosting_web_server_update_6000 Move a lot of fields to the hosting_server table.
hosting_web_server_update_6001 Remove the web_group field which now needs to be consistent between servers.
hosting_web_server_update_6002 Drop the web_server table as it is no longer needed.. Move the restart command value into it's new home in the service table.