function weather_update_2 in Weather 5
Same name and namespace in other branches
- 5.6 weather.install \weather_update_2()
File
- ./weather.install, line 159
Code
function weather_update_2() {
$ret = array();
variable_del('weather_country');
variable_del('weather_icao');
variable_del('weather_icao_name');
variable_del('weather_place');
variable_del('weather_units');
variable_del('weather_use_cron');
$ret[] = update_sql("DELETE FROM {weather}");
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {weather} DROP PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {weather} ADD PRIMARY KEY (icao)");
$ret[] = update_sql("ALTER TABLE {weather} DROP wid");
break;
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {weather} DROP CONSTRAINT {weather}_pkey");
$ret[] = update_sql("ALTER TABLE {weather} ADD PRIMARY KEY (icao)");
$ret[] = update_sql("ALTER TABLE {weather} DROP COLUMN wid");
break;
}
$ret[] = update_sql("DELETE FROM {sequences} WHERE name='{weather_wid}'");
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {weather} CHANGE reported_on next_update_on INTEGER DEFAULT 0 NOT NULL");
break;
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {weather} RENAME COLUMN reported_on TO next_update_on");
break;
}
$sql = "CREATE TABLE {weather_config} (\n uid INTEGER DEFAULT 0 NOT NULL,\n icao VARCHAR(4) DEFAULT '' NOT NULL,\n real_name VARCHAR(255) DEFAULT '' NOT NULL,\n units VARCHAR(8) DEFAULT 'metric' NOT NULL,\n PRIMARY KEY (uid)\n )";
if ($GLOBALS['db_type'] == 'mysql' or $GLOBALS['db_type'] == 'mysqli') {
$sql .= " /*!40100 DEFAULT CHARACTER SET utf8 */";
}
$ret[] = update_sql($sql);
return $ret;
}