You are here

location_fax.install in Location 7.4

Installation routines.

File

contrib/location_fax/location_fax.install
View source
<?php

/**
 * @file
 * Installation routines.
 */

/**
 * Implementation of hook_schema().
 */
function location_fax_schema() {
  $schema['location_fax'] = array(
    'description' => 'location_fax.module {location} supplementary table.',
    'fields' => array(
      'lid' => array(
        'description' => '{location}.lid',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'fax' => array(
        'description' => 'Fax number',
        'type' => 'varchar',
        'length' => 31,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'lid',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function location_fax_install() {

  // Change weight so we execute after location.
  db_update('system')
    ->fields(array(
    'weight' => 1,
  ))
    ->condition('name', 'location_fax')
    ->execute();
}

/**
 * Location 3.0 update 1.
 * Fix pgsql -- The table definition was broken.
 */
function location_fax_update_5300() {
  $ret = array();

  // Drupal 6 note: These should only affect postgresql, but are safe
  // to run on mysql as well, so I don't bother checking db types.
  if (!db_table_exists('location_fax')) {
    db_create_table($ret, 'location_fax', array(
      'fields' => array(
        'lid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'fax' => array(
          'type' => 'varchar',
          'length' => 31,
          'default' => NULL,
        ),
      ),
      'primary key' => array(
        'lid',
      ),
    ));
  }
  return $ret;
}

/**
 * Location 3.0 update 2.
 * Change weight of module.
 */
function location_fax_update_5301() {
  $ret = array();

  // This update was moved to update 5302.
  return $ret;
}

/**
 * Location 3.0 update 2.
 * Change weight of module.
 */
function location_fax_update_5302() {
  db_update('system')
    ->fields(array(
    'weight' => 1,
  ))
    ->condition('name', 'location_fax')
    ->execute();
}

/**
 * Drupal 6 updates.
 */
function location_fax_update_6301() {
  $ret = array();
  db_change_field($ret, 'location_fax', 'fax', 'fax', array(
    'type' => 'varchar',
    'length' => 31,
    'not null' => TRUE,
    'default' => '',
  ));
  return $ret;
}

Functions

Namesort descending Description
location_fax_install Implementation of hook_install().
location_fax_schema Implementation of hook_schema().
location_fax_update_5300 Location 3.0 update 1. Fix pgsql -- The table definition was broken.
location_fax_update_5301 Location 3.0 update 2. Change weight of module.
location_fax_update_5302 Location 3.0 update 2. Change weight of module.
location_fax_update_6301 Drupal 6 updates.