You are here

weather_es.install in Weather_es 7

Install de drupal schema for the weather_es module

@author jmsirvent

File

weather_es.install
View source
<?php

/**
 * @file
 * Install de drupal schema for the weather_es module
 *
 * @author jmsirvent
 */

/**
 * hook_schema()
 */
function weather_es_schema() {
  $schema['weather_es_conf'] = array(
    'description' => t('Stores weather_es user config.'),
    'fields' => array(
      'wid' => array(
        'description' => t('Weather_es uid.'),
        'type' => 'int',
        'default' => 0,
        'not null' => TRUE,
      ),
      'cit_cod' => array(
        'description' => t('City code.'),
        'type' => 'int',
        'precision' => 5,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'lan' => array(
        'description' => t('Language.'),
        'type' => 'varchar',
        'length' => 2,
        'default' => 'en',
      ),
      'inf_typ' => array(
        'description' => t('Information type'),
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
      ),
      'inf_amo' => array(
        'description' => t('Information amount.'),
        'type' => 'varchar',
        'length' => 2,
        'default' => 're',
      ),
    ),
    'primary key' => array(
      'wid',
      'cit_cod',
    ),
  );
  $schema['weather_es_data'] = array(
    'description' => t('Stores weather_es city data.'),
    'fields' => array(
      'cit_cod' => array(
        'description' => t('City code.'),
        'type' => 'int',
        'precision' => 5,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'cit_nam' => array(
        'description' => t('City name.'),
        'type' => 'varchar',
        'length' => 50,
        'default' => '',
      ),
      'nex_upd' => array(
        'description' => t('Next update.'),
        'type' => 'int',
        'precision' => 10,
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
      'dat_dat' => array(
        'description' => 'The AEMET data.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
      ),
    ),
    'primary key' => array(
      'cit_cod',
    ),
  );
  return $schema;
}

/**
 * hook_install().
 */
function weather_es_install() {

  //drupal_install_schema('weather_es');
  db_query("ALTER TABLE {weather_es_conf} CHANGE cit_cod cit_cod INT(5) ZEROFILL DEFAULT 0 NOT NULL");
  db_query("ALTER TABLE {weather_es_data} CHANGE cit_cod cit_cod INT(5) ZEROFILL DEFAULT 0 NOT NULL");
}

/**
 * hook_uninstall().
 */
function weather_es_uninstall() {

  //drupal_uninstall_schema('weather_es');

  // Remove blocks provided by the module
  db_delete('block')
    ->condition('module', 'weather_es')
    ->execute();
  db_delete('block_node_type')
    ->condition('module', 'weather_es')
    ->execute();
  db_delete('block_role')
    ->condition('module', 'weather_es')
    ->execute();
}