function weather_update_1 in Weather 5
Same name and namespace in other branches
- 5.6 weather.install \weather_update_1()
Implementation of hook_update_N().
We use the update hook to clean up the Drupal tables from old variables used by previous versions of this module.
File
- ./
weather.install, line 120
Code
function weather_update_1() {
$ret = array();
// these were used by the official module
variable_del('weather_region');
variable_del('weather_scale');
variable_del('weather_mini_block');
variable_del('weather_extended_forecast');
variable_del('weather_xml_feed');
variable_del('weather_recache_cache');
variable_del('weather_enable_cron');
// these were added by an inofficial module release for Drupal 4.7
variable_del('weather_host');
variable_del('weather_title');
// the table stores every METAR data that has been received
// wid: weather id
// icao: ICAO code of the METAR station
// reported_on: timestamp of report
// metar_raw: raw METAR data, not parsed
$sql = "CREATE TABLE {weather} (\n wid INTEGER DEFAULT 0 NOT NULL,\n icao VARCHAR(4) DEFAULT '' NOT NULL,\n reported_on INTEGER DEFAULT 0 NOT NULL,\n metar_raw VARCHAR(255) DEFAULT '' NOT NULL,\n PRIMARY KEY (wid)\n )";
// ensure the utf8 character set on MySQL (syntax for 4.1 and above)
if ($GLOBALS['db_type'] == 'mysql' or $GLOBALS['db_type'] == 'mysqli') {
$sql .= " /*!40100 DEFAULT CHARACTER SET utf8 */";
}
$ret[] = update_sql($sql);
return $ret;
}