location_phone.install in Location 6.3
Installation routines.
File
contrib/location_phone/location_phone.installView source
<?php
/**
* @file
* Installation routines.
*/
/**
* Implementation of hook_schema().
*/
function location_phone_schema() {
$schema['location_phone'] = array(
'description' => 'location_phone.module {location} supplementary table.',
'fields' => array(
'lid' => array(
'description' => '{location}.lid',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'phone' => array(
'description' => 'Phone number',
'type' => 'varchar',
'length' => 31,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array(
'lid',
),
);
return $schema;
}
/**
* Implementation of hook_install().
*/
function location_phone_install() {
drupal_install_schema('location_phone');
// Change weight.
db_query("UPDATE {system} SET weight = 1 WHERE name = '%s' AND type = '%s'", 'location_phone', 'module');
}
/**
* Implementation of hook_uninstall().
*/
function location_phone_uninstall() {
drupal_uninstall_schema('location_phone');
}
/**
* Location 3.0 update 1.
* Fix pgsql -- The table definition was broken.
*/
function location_phone_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_phone')) {
db_create_table($ret, 'location_phone', array(
'fields' => array(
'lid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'phone' => array(
'type' => 'varchar',
'length' => 31,
'default' => NULL,
),
),
'primary key' => array(
'lid',
),
));
}
else {
// If the table WAS created (i.e. user manually fixed bug and reinstalled), g/c the postal_code column.
if (db_column_exists('location_phone', 'postal_code')) {
db_drop_field($ret, 'location_phone', 'postal_code');
}
}
return $ret;
}
/**
* Location 3.0 update 2.
* Change weight of module.
*/
function location_phone_update_5301() {
$ret = array();
// This update was moved to update 5302.
return $ret;
}
/**
* Location 3.0 update 2.
* Change weight of module.
*/
function location_phone_update_5302() {
$ret = array();
// Change weight.
$ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'location_phone' AND type = 'module'");
return $ret;
}
/**
* Drupal 6 updates.
*/
function location_phone_update_6301() {
$ret = array();
db_change_field($ret, 'location_phone', 'phone', 'phone', array(
'type' => 'varchar',
'length' => 31,
'not null' => TRUE,
'default' => '',
));
return $ret;
}
Functions
Name![]() |
Description |
---|---|
location_phone_install | Implementation of hook_install(). |
location_phone_schema | Implementation of hook_schema(). |
location_phone_uninstall | Implementation of hook_uninstall(). |
location_phone_update_5300 | Location 3.0 update 1. Fix pgsql -- The table definition was broken. |
location_phone_update_5301 | Location 3.0 update 2. Change weight of module. |
location_phone_update_5302 | Location 3.0 update 2. Change weight of module. |
location_phone_update_6301 | Drupal 6 updates. |