function weather_schema in Weather 7
Same name and namespace in other branches
- 6.5 weather.install \weather_schema()
- 7.3 weather.install \weather_schema()
- 7.2 weather.install \weather_schema()
Implement hook_schema().
File
- ./
weather.install, line 106 - Install, update and uninstall functions for the weather module.
Code
function weather_schema() {
$schema['weather_metar'] = array(
'description' => 'Raw and parsed METAR data for all currently used ICAO codes.',
'fields' => array(
'icao' => array(
'description' => 'ICAO code of the METAR station.',
'type' => 'varchar',
'length' => 4,
'not null' => TRUE,
'default' => '',
),
'reported_on' => array(
'description' => 'UTC time of weather report.',
'type' => 'int',
'not null' => TRUE,
),
'next_update_on' => array(
'description' => 'UTC time of next scheduled update.',
'type' => 'int',
'not null' => TRUE,
),
'sky_condition' => array(
'description' => 'Sky condition, cloud covering.',
'type' => 'varchar',
'length' => 25,
'not null' => FALSE,
'default' => NULL,
),
'phenomena' => array(
'description' => 'Phenomena like rain, snow, thunderstorm.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => NULL,
),
'temperature' => array(
'description' => 'Temperature in degree celsius.',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
),
'dewpoint' => array(
'description' => 'Dewpoint temperature in degree celsius.',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
),
'wind_direction' => array(
'description' => 'Wind direction in degrees.',
'type' => 'varchar',
'length' => 8,
'not null' => FALSE,
'default' => NULL,
),
'wind_speed' => array(
'description' => 'Wind speed in km/h.',
'type' => 'float',
'not null' => FALSE,
'default' => NULL,
),
'wind_gusts' => array(
'description' => 'Wind gust speed in km/h.',
'type' => 'float',
'not null' => FALSE,
'default' => NULL,
),
'pressure' => array(
'description' => 'Pressure in hPa.',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
),
'visibility' => array(
'description' => 'Visibility in meter.',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
),
'sunrise_on' => array(
'description' => 'UTC time of sunrise (NULL if there is no sunrise).',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
),
'sunset_on' => array(
'description' => 'UTC time of sunset (NULL if there is no sunset).',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
),
'image' => array(
'description' => 'Filename of the weather image file.',
'type' => 'varchar',
'length' => 35,
'not null' => FALSE,
'default' => NULL,
),
'raw' => array(
'description' => 'Raw METAR data.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
),
'primary key' => array(
'icao',
),
);
$schema['weather_location'] = array(
'description' => 'Configuration of a location.',
'fields' => array(
'id' => array(
'description' => 'Location 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,
),
'icao' => array(
'description' => 'ICAO code of the METAR station.',
'type' => 'varchar',
'length' => 4,
'not null' => TRUE,
'default' => '',
),
'real_name' => array(
'description' => 'The name to display for the ICAO code.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'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_display' => 'type',
),
'display_number' => array(
'weather_display' => 'number',
),
),
);
$schema['weather_display'] = array(
'description' => 'Configuration of a display (for example, a block).',
'fields' => array(
'type' => array(
'description' => 'Type of display (system-wide, user, location, default, ...).',
'type' => 'varchar',
'length' => 20,
'not null' => TRUE,
'default' => '',
),
'number' => array(
'description' => 'Display number.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'units' => array(
'description' => 'Units for display (Celsius/Fahrenheit, mmHg/hPa etc.).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'serialize' => TRUE,
),
'settings' => array(
'description' => 'Settings for display (Show raw METAR, abbrev. wind directions etc.).',
'type' => 'text',
'size' => 'normal',
'not null' => TRUE,
'serialize' => TRUE,
),
),
'primary key' => array(
'type',
'number',
),
);
$schema['weather_icao'] = array(
'description' => 'Contains all known ICAO codes with further information.',
'fields' => array(
'icao' => array(
'description' => 'ICAO code of the METAR station.',
'type' => 'varchar',
'length' => 4,
'not null' => TRUE,
'default' => '',
),
'country' => array(
'description' => 'Name of the country.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'name' => array(
'description' => 'Name of the METAR station.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'latitude' => array(
'description' => 'Location of METAR station, latitude.',
'type' => 'float',
'size' => 'big',
'not null' => TRUE,
'default' => 0.0,
),
'longitude' => array(
'description' => 'Location of METAR station, longitude.',
'type' => 'float',
'size' => 'big',
'not null' => TRUE,
'default' => 0.0,
),
),
'primary key' => array(
'icao',
),
);
return $schema;
}