View source
<?php
function hosting_package_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {hosting_package} (\n vid int NOT NULL default '0',\n nid int(10) unsigned NOT NULL default '0',\n package_type varchar(16) NOT NULL default '',\n short_name longtext NOT NULL default '',\n description longtext NOT NULL default '',\n PRIMARY KEY (vid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {hosting_package_instance} (\n iid int NOT NULL DEFAULT '0',\n rid int(11) NOT NULL default '0',\n package_id int(11) NOT NULL default '0',\n filename longtext NOT NULL DEFAULT '',\n schema_version int(10) NOT NULL default '0',\n version longtext NOT NULL default '',\n status int(1) NOT NULL default '0',\n PRIMARY KEY (iid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {hosting_package_languages} (\n iid int NOT NULL,\n language VARCHAR(12) NOT NULL DEFAULT ''\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
break;
}
}
function hosting_package_update_1() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {hosting_package} ADD COLUMN description longtext NOT NULL default ''");
return $ret;
}
function hosting_package_update_2() {
$ret = array();
$ret[] = update_sql("CREATE TABLE {hosting_package_languages} (\n vid int NOT NULL,\n nid int(10) UNSIGNED NOT NULL,\n language VARCHAR(12) NOT NULL DEFAULT ''\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
return $ret;
}
function hosting_package_update_3() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {hosting_package} MODIFY COLUMN short_name longtext NOT NULL default ''");
return $ret;
}
function hosting_package_update_4() {
include_once drupal_get_path('module', 'hosting_task') . '/hosting_task.module';
$ret = array();
$ret[] = update_sql("DROP TABLE {hosting_package_languages}");
$ret[] = update_sql("CREATE TABLE {hosting_package_languages} (\n iid int UNSIGNED NOT NULL,\n language VARCHAR(12) NOT NULL DEFAULT ''\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
$result = db_query("SELECT nid FROM {node} WHERE type='platform' AND status=1");
while ($platform = db_fetch_object($result)) {
hosting_add_task($platform->nid, 'verify');
}
return $ret;
}
function hosting_package_update_5() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {hosting_package_instance} ADD COLUMN package_id int(10) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {hosting_package_instance} ADD COLUMN version longtext NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {hosting_package_instance} ADD COLUMN filename longtext NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {hosting_package_instance} ADD COLUMN schema_version int(10) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {hosting_package_instance} ADD COLUMN status int(1) NOT NULL default '0'");
$platforms = _hosting_get_platforms();
foreach ($platforms as $nid => $name) {
$platform = db_fetch_object(db_query("SELECT release_id FROM {hosting_platform} WHERE nid=%d", $nid));
$release = db_fetch_object(db_query("SELECT * FROM {hosting_package_release} WHERE nid = %d", $platform->release_id));
$instance = new stdClass();
$instance->rid = $nid;
$instance->package_id = $release->package;
$instance->version = $release->version;
$instance->filename = '';
$instance->schema_version = 0;
hosting_package_instance_save($instance);
hosting_add_task($nid, 'verify');
}
$ret[] = update_sql("ALTER TABLE {hosting_platform} DROP COLUMN release_id");
$result = db_query("SELECT * FROM {hosting_package_release}");
while ($release = db_fetch_object($result)) {
db_query("UPDATE {hosting_package_instance} SET version='%s', schema_version=%d, package_id=%d WHERE release_id=%d", $release->version, $release->schema_version, $release->package, $release->nid);
}
$ret[] = update_sql("DELETE FROM {node_revisions} WHERE nid IN (SELECT nid FROM {node} WHERE type='package_release')");
$ret[] = update_sql("DELETE FROM {node} WHERE type='package_release'");
$ret[] = update_sql("ALTER TABLE {hosting_package_instance} DROP COLUMN release_id");
$ret[] = update_sql("ALTER TABLE {hosting_package_instance} DROP COLUMN path");
$ret[] = update_sql("DROP TABLE {hosting_package_release}");
return $ret;
}
function hosting_package_update_6() {
$ret = array();
$ret[] = update_sql("DELETE FROM {hosting_package_instance}");
$ret[] = update_sql("UPDATE {sequences} SET id=1 WHERE name='{hosting_package_instance}_iid'");
$result = db_query("SELECT nid FROM {node} WHERE type='platform' AND status=1");
while ($platform = db_fetch_object($result)) {
hosting_add_task($platform->nid, 'verify');
}
$result = db_query("SELECT nid FROM {node} WHERE type='site' AND status=1");
while ($site = db_fetch_object($result)) {
hosting_add_task($site->nid, 'verify');
}
return $ret;
}