You are here

function weather_schema in Weather 7.2

Same name and namespace in other branches
  1. 6.5 weather.install \weather_schema()
  2. 7.3 weather.install \weather_schema()
  3. 7 weather.install \weather_schema()

Implements hook_schema().

File

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

Code

function weather_schema() {
  $schema['weather_displays'] = array(
    'description' => 'Configuration of weather displays.',
    'fields' => array(
      'type' => array(
        'description' => 'Type of display (system-wide, user, default).',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'number' => array(
        'description' => 'Display number.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'config' => array(
        'description' => 'Configuration for display (units and settings).',
        'type' => 'text',
        'size' => 'normal',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'type',
      'number',
    ),
  );
  $schema['weather_places'] = array(
    'description' => 'Information about known places at yr.no.',
    'fields' => array(
      'geoid' => array(
        'description' => 'GeoID of the location.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'latitude' => array(
        'description' => 'Latitude of location.',
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'longitude' => array(
        'description' => 'Longitude of location.',
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'country' => array(
        'description' => 'Country of location.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'Name of location.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'link' => array(
        'description' => 'Shortened link of location at yr.no.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'description' => 'Status of place',
        'type' => 'varchar',
        'length' => 8,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'geoid',
    ),
  );
  $schema['weather_displays_places'] = array(
    'description' => 'Places used in weather displays.',
    'fields' => array(
      'id' => array(
        'description' => 'ID.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'display_type' => array(
        'description' => 'Type of display (system-wide, user, location, default, ...).',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'display_number' => array(
        'description' => 'Display number.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'place_geoid' => array(
        'description' => 'GeoID of the place.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'displayed_name' => array(
        'description' => 'Displayed name of place.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'weight' => array(
        'description' => 'Weight of the location.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'foreign keys' => array(
      'display_type' => array(
        'weather_displays' => 'type',
      ),
      'display_number' => array(
        'weather_displays' => 'number',
      ),
      'place_geoid' => array(
        'weather_places' => 'geoid',
      ),
    ),
  );
  $schema['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',
    ),
  );
  $schema['weather_forecast_information'] = array(
    'description' => 'Information about the forecast data for a place.',
    'fields' => array(
      'geoid' => array(
        'description' => 'GeoID of the location.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'last_update' => array(
        'description' => 'UTC time of last update.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'next_update' => array(
        'description' => 'UTC time of next scheduled update.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'next_download_attempt' => array(
        'description' => 'UTC time of next scheduled download attempt.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'utc_offset' => array(
        'description' => 'UTC offset of local time in minutes.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'geoid',
    ),
  );
  return $schema;
}