You are here

weather_es.install in Weather_es 6.2

Non-displayable characters.

File

weather_es.install
View source
<?php




function weather_es_schema() {
  $schema['weather_es_config'] = array(
    'description' => t('Weather_es configuration data.'),
    'fields' => array(
      'uid' => array(
        'description' => t('User ID.'),
        'type' => 'int',
        'precision' => 3,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'cod_pro' => array(
        'description' => t('AEMET province code.'),
        'type' => 'int',
        'precision' => 2,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'cod_loc' => array(
        'description' => t('AEMET location code.'),
        'type' => 'int',
        'precision' => 3,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'cit_nam' => array(
        'description' => t('City name.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'lan' => array(
        'description' => t('Language.'),
        'type' => 'varchar',
        'length' => 2,
        'default' => 'es',
      ),
      'pro_act' => array(
        'description' => t('Next update.'),
        'type' => 'int',
        'precision' => 10,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'sky' => array(
        'description' => t('Sky info.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'rain' => array(
        'description' => t('Rain probability.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'snow' => array(
        'description' => t('Snow level.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'tmax' => array(
        'description' => t('Maximun temperature.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'tmin' => array(
        'description' => t('Minimum temperature.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'win_dir' => array(
        'description' => t('Wind direction.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'win_spd' => array(
        'description' => t('Wind speed.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'iv' => array(
        'description' => t('Violet index.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'rsk' => array(
        'description' => t('Risk level.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'uid',
      'cod_pro',
      'cod_loc',
    ),
  );
  $schema['weather_es_data'] = array(
    'description' => t('Weather_es data.'),
    'fields' => array(
      'did' => array(
        'description' => t('Data ID.'),
        'type' => 'serial',
        'size' => 'small',
        'not null' => TRUE,
      ),
      'cod_pro' => array(
        'description' => t('AEMET province code.'),
        'type' => 'int',
        'precision' => 2,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'cod_loc' => array(
        'description' => t('AEMET location code.'),
        'type' => 'int',
        'precision' => 3,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'day' => array(
        'description' => t('Day name.'),
        'type' => 'varchar',
        'length' => 15,
        'default' => '',
      ),
      'ampm' => array(
        'description' => t('AMP or PM.'),
        'type' => 'varchar',
        'length' => 2,
        'default' => '',
      ),
      'sky_txt1' => array(
        'description' => t('AM sky info.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'sky_txt2' => array(
        'description' => t('PM sky info.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'sky_img1' => array(
        'description' => t('AM sky image.'),
        'type' => 'varchar',
        'length' => 25,
        'default' => 'nodata',
      ),
      'sky_img2' => array(
        'description' => t('PM sky image.'),
        'type' => 'varchar',
        'length' => 25,
        'default' => 'nodata',
      ),
      'rain' => array(
        'description' => t('Rain probability.'),
        'type' => 'int',
        'precision' => 3,
        'unsigned' => TRUE,
        'default' => 999,
      ),
      'snow' => array(
        'description' => t('Snow level in metres.'),
        'type' => 'int',
        'precision' => 4,
        'unsigned' => TRUE,
        'default' => 9999,
      ),
      'tmax' => array(
        'description' => t('Maximum temperature.'),
        'type' => 'int',
        'precision' => 2,
        'default' => 99,
      ),
      'tmin' => array(
        'description' => t('Minimum temperature.'),
        'type' => 'int',
        'precision' => 2,
        'default' => 99,
      ),
      'win_dir1' => array(
        'description' => t('AM wind direction.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'win_dir2' => array(
        'description' => t('PM wind direction.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'win_spd1' => array(
        'description' => t('AM wind speed in km/h.'),
        'type' => 'int',
        'precision' => 3,
        'unsigned' => TRUE,
        'default' => 999,
      ),
      'win_spd2' => array(
        'description' => t('PM wind speed in km/h.'),
        'type' => 'int',
        'precision' => 3,
        'unsigned' => TRUE,
        'default' => 999,
      ),
      'iv_max' => array(
        'description' => t('Violet index.'),
        'type' => 'int',
        'precision' => 2,
        'unsigned' => TRUE,
        'default' => 99,
      ),
      'rsk' => array(
        'description' => t('Risk level.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'cod_pro',
      'cod_loc',
      'did',
    ),
  );
  $schema['weather_es_aemet'] = array(
    'description' => t('Weather_es data.'),
    'fields' => array(
      'cod_pro' => array(
        'description' => t('AEMET province code.'),
        'type' => 'int',
        'precision' => 2,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'cod_loc' => array(
        'description' => t('AEMET location code.'),
        'type' => 'int',
        'precision' => 3,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'cit_nam' => array(
        'description' => t('City name.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'cod_pro',
      'cod_loc',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function weather_es_install() {
  drupal_install_schema('weather_es');
  db_query("ALTER TABLE {weather_es_config} CHANGE cod_pro cod_pro INT(2) ZEROFILL DEFAULT 0 NOT NULL");
  db_query("ALTER TABLE {weather_es_config} CHANGE cod_loc cod_loc INT(3) ZEROFILL DEFAULT 0 NOT NULL");
  db_query("ALTER TABLE {weather_es_data} CHANGE cod_pro cod_pro INT(2) ZEROFILL DEFAULT 0 NOT NULL");
  db_query("ALTER TABLE {weather_es_data} CHANGE cod_loc cod_loc INT(3) ZEROFILL DEFAULT 0 NOT NULL");
  db_query("ALTER TABLE {weather_es_aemet} CHANGE cod_pro cod_pro INT(2) ZEROFILL DEFAULT 0 NOT NULL");
  db_query("ALTER TABLE {weather_es_aemet} CHANGE cod_loc cod_loc INT(3) ZEROFILL DEFAULT 0 NOT NULL");

  // Insert the AEMET cities code
  require_once drupal_get_path('module', 'weather_es') . '/weather_es_data.inc';
  _weather_es_fill_aemet_table();
}

/**
 * Implementation of hook_uninstall().
 */
function weather_es_uninstall() {
  drupal_uninstall_schema('weather_es');
}

Functions

Namesort descending Description
weather_es_install Implementation of hook_install().
weather_es_schema Non-displayable characters.
weather_es_uninstall Implementation of hook_uninstall().