You are here

function weather_update_7205 in Weather 7.3

Same name and namespace in other branches
  1. 7.2 weather.install \weather_update_7205()

Add an ID to the weather_forecasts table, in order to use views.

File

./weather.install, line 753
Install, update and uninstall functions for the weather module.

Code

function weather_update_7205(&$sandbox) {

  // Remove old table and forecasts, need to be downloaded again.
  db_drop_table('weather_forecasts');

  // Remove forecast information.
  db_truncate('weather_forecast_information')
    ->execute();

  // Create new table.
  db_create_table('weather_forecasts', array(
    'description' => 'Parsed XML forecast data from yr.no.',
    'fields' => array(
      'id' => array(
        'description' => 'ID.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'geoid' => array(
        'description' => 'GeoID of the location.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'time_from' => array(
        'description' => 'Start time of forecast.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'time_to' => array(
        'description' => 'End time of forecast.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'period' => array(
        'description' => 'Period of day.',
        'type' => 'varchar',
        'length' => 1,
        'not null' => TRUE,
        'default' => '',
      ),
      'symbol' => array(
        'description' => 'Symbol to use for weather display.',
        'type' => 'varchar',
        'length' => 3,
        'not null' => TRUE,
        'default' => '',
      ),
      'precipitation' => array(
        'description' => 'Amount of precipitation in mm.',
        'type' => 'float',
        'size' => 'big',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'wind_direction' => array(
        'description' => 'Wind direction in degrees.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'wind_speed' => array(
        'description' => 'Wind speed in m/s.',
        'type' => 'float',
        'size' => 'big',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'temperature' => array(
        'description' => 'Temperature in degree celsius.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'pressure' => array(
        'description' => 'Pressure in hPa.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  ));
}